Hi,
When the file contains the column names (as is best practice) then any
text after the last column is read (such as comments) is ignored (with
warning is intended). Some improvement here could be made but comments
in large files isn't something that's come up before. fread isn't a drop
in replacement for read.table yet, but it would be good if it was.
If fread is reading your comments into a column, then I guess the first
row is data row and the last column contains the comments. Just delete
the comments afterwards using DT[,lastcolumn:=NULL]. Or include column
names in the file.
To hard-name columns, can use setnames() afterwards (either to rename
old to new names, or to overwrite whatever names are there, if any).
If you want to read a subset of columns, use 'select' argument.
The plan is to create a wrapper for fread that can be used as a drop in
replacement for read.table.
Are your files large and did you create them or are they given?
Matthew
On 05/08/13 19:18, iembry wrote:
Hi Matthew, thank you for your prompt response.
I am experimenting with fread and I am having a problem with comments not
being ignored. In read.table, I can ignore the comments and create column
names. I have not seen any way to either create column names or ignore
comments within the fread function.
How would I use fread to both ignore the comments and also to add column
names as I can with read.table?
ratingdepostlistedread <- fread("03217500.exsa.rdb", sep="auto",
sep2="auto", header="auto", na.strings="NA", stringsAsFactors=FALSE,
verbose=FALSE))
ratingdepostlisted <- read.table("03217500.exsa.rdb", sep = "\t", fill =
TRUE, comment.char = "#", header = T, as.is = TRUE, stringsAsFactors =
FALSE, na.strings = "NA", col.names = c("y", "shift", "x", "stor")
Thank you.
Irucka
--
View this message in context:
http://r.789695.n4.nabble.com/data-table-on-existing-data-frame-list-tp4673142p4673172.html
Sent from the datatable-help mailing list archive at Nabble.com.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help