[R] Ignoring missing elements in data.frame()

Scott Chamberlain schamber at rice.edu
Sat Jun 5 01:23:38 CEST 2010


Hello, I am trying to make a data frame from many elements after
running a function which creates many elements, some of which may not
end up being real elements due to errors or missing data. For example,
I have the following three elements p1s, p2s, and p3s. p9s did not
generate the same data as there was an error in the function for some
reason. I currently have to delete p9s from the data.frame() command
to get the data.frame to work.  How can I make a data frame by somehow
ignoring elements (e.g., p9s) that do not exist, without having to
delete each missing element from data.frame()? The below is an example
of the code.

> p1s
     statistic parameter p.value
[1,] 3.606518  153       0.0004195377
> p2s
     statistic parameter p.value
[1,] -3.412436 8         0.009190015
> p3s
     statistic parameter p.value
[1,] 1.543685  599       0.1231928

> t(data.frame(t(p1s),t(p2s),t(p3s),t(p9s)))
Error in t(p9s) : object 'p9s' not found


Thanks, Scott Chamberlain
Rice University
Houston, TX



More information about the R-help mailing list