Skip to content
Prev 360650 / 398503 Next

R column assignment fails for lists

Dear Jim and David,

Thank you very much for your reply. I guess my question is whether it is
legal to store vectors in the elements of a data.frame. These are useful
for storing things like neighbors of a graph vertex, orthologs of a gene
etc. I have been using data frames of this sort and they are very useful,
so I am hoping this is a feature, rather than a bug. The weird code in my
email to form a was just one quick way of making such an object for a toy
example. These sort of data frames were doing fine for a number of analysis
pipelines until I used a function on them that had code of the sort
df[, j] <- sapply(df[, j], fun)

The interesting thing is that while
a[,3] <- a[,3] changes the object and gives the warning
a$c <- a$c works "correctly". leaving a to what it was and doesn't give a
warning.

If elements of a data frame are supposed to be able to store vectors, then
shouldn't
a[,3] <- a[,3] work?

Best regards,
yasir


On Tue, May 3, 2016 at 9:48 PM, David Winsemius <dwinsemius at comcast.net>
wrote: