Hi,

In general you need to convert the data.frame to a data.table before you can use data.table syntax and features on it :

    DT = as.data.table(DF)

But that's a copy of the whole objects so it's easier and faster to start off with a data.table in the first place; e.g., using fread as you said. Its development status means that fread's current argument names, types and order might possibly change a bit in a backwards incompatible way. It isn't intended to convey that it's too flaky for end user use. Quite a few people are already using it routinely.

If you have a list of many data.frame's, then that's difficult work with. My first thought would be to pass that to rbindlist to create one large data.table, then := by group to add the column.

Matthew

On 05/08/13 16:36, iembry wrote:
Hi all, I am new to data.table and I have some questions.

Since fread is still in development stage, I have not used it to read my
data files stored on the disk. I have used read.table and the objects are
stored as data.frame.

How do I use data.table on those existing data.frame objects?

This is a reproducible example:

dput(df)
structure(list(a = c(5, 6, 6), b = c(20.2, 32.9, 0.99), cdo = c(0.2,
32, 90.34)), .Names = c("a", "b", "cdo"), row.names = c(NA, -3L
), class = "data.frame")


In my real data set, I have a list of many data frames where I will need to
change an existing column.

For example, in the "df" data.frame, how would I make a revised "a" = "a" +
"b"?

The code below represents what I am attempting to do with my real data set:

getratings2 <- lapply(seq_along(dailyvaluesneednew$site_no), function(u)
getratings[[u]]$y <- getratings[[u]]$y + getratings[[u]]$shift)

In this case, I would like to make the column named "y" = "y" + "shift" and
perform that operation for each data.frame in the list.

Thank you.

Irucka Embry



--
View this message in context: 
http://r.789695.n4.nabble.com/data-table-on-existing-data-frame-list-tp4673142.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

Reply via email to