Skip to content

wait, t(sapply()) does not work

2 messages · Remko Duursma, Spencer Graves

#
I just noticed that the code

data.frame(t(sapply(tester.L, function(x) x <- x[1,])))

does not result in a nice dataframe, although is.data.frame gives TRUE. It works on the small example in the previous emails, but something weird happens for a larger dataset.

remko
#
What are the symptoms?

Do "sapply(tester.L, data.class)".  If some of the attributes of 
tester.L are data.frames, then do, e.g., "sapply(tester.L[[1]], 
data.class)".  If the objects passed to "function(x) x <- x[1,]" are 
data.frames, the ouput of "function(x)x <- x[1,]" may be a list, not a 
vector, with attributes of different classes.

Spencer
Remko Duursma wrote: