[R] Data.frames : difference between x$a and x[, "a"] ? - How set new values on x$a with a as variable ?

David Winsemius dwinsemius at comcast.net
Fri Sep 10 16:13:02 CEST 2010


On Sep 10, 2010, at 9:42 AM, Hadley Wickham wrote:

>>>> I'm having trouble parsing this. What exactly do you want to do?
>>> 1 - Put a list as an element of a data.frame. That's quite  
>>> convenient for my pricing function.
>>
>> I think this is a really bad idea. data.frames are not meant to be
>> used in this way. Why not use a list of lists?
>
> It can be very convenient, but I suspect the original poster is
> confused about the different between vectors and lists.

I wouldn't be surprised if someone were confused, since my reading of  
some (but not all) of the help documents has led me to think that  
lists _were_ vectors, just not vectors of atomic mode. And one oft- 
illustrated method for creating a list is:  alist <-  
vector(mode="list", length=10). I am perhaps less confused than I was  
two years ago but my confusion about all the possible permutations of  
mode, typeof, expression, formula, and class and the extraction  
methods therefrom definitely persists. I think the authors of the  
documentation are of divided opinion or usage on this topic.

Best;
David.


>
> Hadley
>
> -- 
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list