[R] Reading parameters from dataframe and loading as objects

Aher ajit.aher at cedar-consulting.com
Fri Nov 4 07:24:47 CET 2011


Hi List,

I want to read several parameters from data frame and load them as object
into R session, Is there any package or function in R for this?? 

Here is example
 
param <-c("clust_num", "minsamp_size", "maxsamp_size", "min_pct", "max_pct") 
value <-c(15, 20000, 200000, 0.001, .999) 
data <- data.frame ( cbind(param , value))
data
         param       value
1    clust_num     15
2 minsamp_size    20000
3 maxsamp_size   2e+05
4      min_pct      0.001
5      max_pct     0.999

My data contains many such parameters, I need to read each parameter and its
value from the data and load it as objects  in R session as below:

clust_num  <-   15
minsamp_size  <-20000
maxsamp_size <-2e+05
min_pct <-0.001
max_pct <-0.999

The way right now I am doing it is as creating as many variables as
parameters in the data frame and one observation for value of each
parameter.  
example:
clust_num	minsamp_size	maxsamp_size	min_pct	max_pct
15	20000	200000	0.001	0.999

data$ clust_num  , data$minsamp_size,  .....

Is there any better way for doing this?


--
View this message in context: http://r.789695.n4.nabble.com/Reading-parameters-from-dataframe-and-loading-as-objects-tp3989150p3989150.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list