[R] data.table evaluating columns

Matthew Dowle mdowle at mdowle.plus.com
Wed Mar 3 15:39:15 CET 2010


That in itself is a question for the maintainer, off r-help. When the 
posting guide says "contact the package maintainer first" it means it 
literally and applies even to questions about the existence of a mailing 
list for the package.  So what I'm supposed to do now is tell you how the 
posting guide works, and tell you that I'll reply off list.  Then hopefully 
the community will be happy with me too.  So I'll reply off list :-)

"Rob Forler" <rforler at uchicago.edu> wrote in message 
news:eb472fec1003030502s4996511ap8dfd32dddd9a3ca1 at mail.gmail.com...
> Okay I appreciate the help, and I appreciate the FAQ reminder. I will read
> the r-help posting guide. I'm relatively new to using the support systems
> around R. So far everyone has been really helpful.
>
> I'm confused as to which data.table "list" I should be using.
> http://lists.r-forge.r-project.org/pipermail/datatable-commits/ doesn't
> appear to be correct. Or just directly sending an email to all of you?
>
> Thanks again,
> Rob
>
>
>
> On Wed, Mar 3, 2010 at 6:05 AM, Matthew Dowle 
> <mdowle at mdowle.plus.com>wrote:
>
>>
>> I'd go a bit further and remind that the r-help posting guide is clear :
>>
>>  " For questions about functions in standard packages distributed with R
>> (see the FAQ Add-on packages in R), ask questions on R-help.
>> If the question relates to a contributed package , e.g., one downloaded
>> from
>> CRAN, try contacting the package maintainer first. You can also use
>> find("functionname") and packageDescription("packagename") to find this
>> information. ONLY send such questions to R-help or R-devel if you get no
>> reply or need further assistance. This applies to both requests for help
>> and
>> to bug reports. "
>>
>> The "ONLY" is in bold in the posting guide. I changed the bold to 
>> capitals
>> above for people reading this in text only.
>>
>> Since Tom and I are friendly and responsive, users of data.table don't
>> usually make it to r-help. We'll follow up this one off-list.  Please 
>> note
>> that Rob's question is very good by the rest of the posting guide, so no
>> complaints there, only that it was sent to the wrong place.  Please keep
>> the
>> questions coming, but send them to us, not r-help.
>>
>> You do sometimes see messages to r-help starting something like "I have
>> contacted the authors/maintainers but didn't hear back,  does anyone know
>> ...".   To not state that they had would be an implicit request for 
>> further
>> work by the community (for free) to ask if they had. So its not enough to
>> contact the maintainer first, but you also have to say that you have as
>> well, and perhaps how long ago too would be helpful.  For r-forge 
>> projects
>> I
>> usually send any question to everyone on the project (easy to find) or if
>> they have a list then to that.
>>
>> HTH
>> Matthew
>>
>>
>> "Tom Short" <tshort.rlists at gmail.com> wrote in message
>> news:fd27013a1003021718w409acb32r1281dfeca559314a at mail.gmail.com...
>> On Tue, Mar 2, 2010 at 7:09 PM, Rob Forler <rforler at uchicago.edu> wrote:
>> > Hi everyone,
>> >
>> > I have the following code that works in data frames taht I would like 
>> > tow
>> > ork in data.tables . However, I'm not really sure how to go about it.
>> >
>> > I basically have the following
>> >
>> > names = c("data1", "data2")
>> > frame = data.frame(list(key1=as.integer(c(1,2,3,4,5,6)),
>> > key2=as.integer(c(1,2,3,2,5,6)),data1 = c(3,3,2,3,5,2), data2=
>> > c(3,3,2,3,5,2)))
>> >
>> > for(i in 1:length(names)){
>> > frame[, paste(names[i], "flag")] = frame[,names[i]] < 3
>> >
>> > }
>> >
>> > Now I try with data.table code:
>> > names = c("data1", "data2")
>> > frame = data.table(list(key1=as.integer(c(1,2,3,4,5,6)),
>> > key2=as.integer(c(1,2,3,2,5,6)),data1 = c(3,3,2,3,5,2), data2=
>> > c(3,3,2,3,5,2)))
>> >
>> > for(i in 1:length(names)){
>> > frame[, paste(names[i], "flag"), with=F] = as.matrix(frame[,names[i],
>> > with=F] )< 3
>> >
>> > }
>>
>> Rob, this type of question is better for the package maintainer(s)
>> directly rather than R-help. That said, one answer is to use list
>> addressing:
>>
>> for(i in 1:length(names)){
>>    frame[[paste(names[i], "flag")]] = frame[[names[i]]] < 3
>> }
>>
>> Another option is to manipulate frame as a data frame and convert to
>> data.table when you need that functionality (conversion is quick).
>>
>> In the data table version, frame[,names[i], with=F] is the same as
>> frame[,names[i], drop=FALSE] (the answer is a list, not a vector).
>> Normally, it's easier to use [[]] or $ indexing to get this. Also,
>> fname[i,j] <- something assignment is still a bit buggy for
>> data.tables.
>>
>> - Tom
>>
>> Tom Short
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>



More information about the R-help mailing list