[R] ls() pattern

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Thu Dec 13 16:19:56 CET 2007


> I get some data in the following format and I would like to combine them 
to
> form a dataframe. 
>
> The data is like:
> 
> cbcname1 = 0.1,
> cbcname2= 0.2,
> cbcname3=0.3,...
> 
> name1, name2, name2 are just some random names. I would like to achieve 
sth
> like:
> (cbcname1=0.1, cbcname2=0.2, cbcname3=0.3,......)
> 
> I am using the following codes
> do.call(cbind, ls(pat=paste("cbc",*,"=")))

Try this:

unlist(mget(ls(pattern="cbc"), envir=.GlobalEnv))

The output is an array rather than a data frame, but so would be the 
output from cbind.

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list