On Nov 4, 2011, at 1:50 PM, "Francois Pepin" <francois.pe...@sequentainc.com> wrote:
> Hi, > > assign is your friend here: > apply(data,1,function(x)assign(x[1],x[2],envir = .GlobalEnv)) > > As a note, you probably don't want to use data as a variable because it > overwrites the data function, leading to unwanted side-effects if you ever > use it. While it is true that using "data" as an object name is a bad choice, the specific reason offered is incorrect. Functions are kept in a different list from other named objects and creating a "data" data.frame will NOT overwrite the data function. -- David. > > Cheers, > > François Pepin > Scientist > > Sequenta, Inc. > 400 E. Jamie Court, Suite 301 > South San Francisco, CA 94080 > > 650 243 3929 p > > francois.pe...@sequentainc.com > www.sequentainc.com > > The contents of this e-mail message and any attachments are intended solely > for the addressee(s) named in this message. This communication is intended > to be and to remain confidential and may be subject to applicable > attorney/client and/or work product privileges. If you are not the intended > recipient of this message, or if this message has been addressed to you in > error, please immediately alert the sender by reply e-mail and then delete > this message and its attachments. Do not deliver, distribute or copy this > message and/or any attachments and if you are not the intended recipient, do > not disclose the contents or take any action in reliance upon the information > contained in this communication or any attachments. > > On Nov 3, 2011, at 23:24 , Aher wrote: > >> 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. >> >> ______________________________________________ >> R-help@r-project.org 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. > > ______________________________________________ > R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.