Ich lese Dateien mit fread()
. Bei einigen Dateien habe ich die folgende Situation:Datenverlust bei `fread()` aufgrund von NA auf Zeichen
dt1 <- fread('colA colB colC
A01 NA NA
A02 NA NA
A03 NA NA
A04 NA NA
A05 NA NA
A06 NA NA
A07 bbb NA
A08 NA ccc
A09 NA NA
A10 NA NA
A11 NA NA
A12 NA NA
A13 NA NA
A14 NA NA
A15 NA NA
A16 NA NA
A17 NA NA
A18 NA NA
')
Bumped column 2 to type character on data row 7, field contains 'bbb'. Coercing previously read values in this column from logical, integer or numeric back to character which may not be lossless; e.g., if '00' and '000' occurred before they will now be just '0', and there may be inconsistencies with treatment of ',,' and ',NA,' too (if they occurred in this column before the bump). If this matters please rerun and set 'colClasses' to 'character' for this column. Please note that column type detection uses the first 5 rows, the middle 5 rows and the last 5 rows, so hopefully this message should be very rare. If reporting to datatable-help, please rerun and include the output from verbose=TRUE.
dt1
# colA colB colC
# 1: A01 NA
# 2: A02 NA
# 3: A03 NA
# 4: A04 NA
# 5: A05 NA
# 6: A06 NA
# 7: A07 bbb NA
# 8: A08 NA ccc
# 9: A09 NA NA
# 10: A10 NA NA
In den resultierenden data.table, colB Werte vor dem ersten Zeichen Vorkommen sind leere Strings statt NA
. Ich kenne Spaltennamen oder Spaltennummern nicht im Voraus, daher kann ich das Argument colClasses
nicht verwenden. Gibt es eine Möglichkeit, dies zu lösen (neben der Verwendung von read.table()
anstelle von fread()
)?
Verwenden Sie keine Angebotsformatierung für Text, der nicht zitiert wird. – EJP
@EJP, betrachtete ich dies als ein Zitat der Fehlermeldung - Was ist die korrekte Formatierung für diesen Fall? ohne Formatierung sieht es wie mein eigener Text aus, der es weniger klar macht –
Ich setze Codeformatierung dann (sehe noch nicht, was das Problem der Zitatformatierung war - es sah besser aus, imho) –