[R] Need help with dataset formation problem

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Sep 20 01:06:38 CEST 2006

Tong Wang wrote:

> Hi, I have a data set , say, X  :      [1]    [2] mean      0      .8
>  sd        1       3
> I need to use it in do.call() ,   so when I refer to the first col of
> X, I need it to be a list with members mean, sd. thus I constructed X
> as a list of list :  X[[1]]<- list(mean=0, sd=1),   X[[2]]<-.....
> .  But this dataset is useless in other cases, for example, I can't
> pull out all the means as a vector. Can I get some suggestions on

You can:

sapply(X, "[[", 1)

Uwe Ligges

> what's the best way to handle it? (except preparing two copies of
> this data with different formats)
> Thanks a lot in advance.
> best
> ______________________________________________ 
> R-help at stat.math.ethz.ch 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.

More information about the R-help mailing list