[R] question

PIKAL Petr petr.pikal at precheza.cz
Fri Jul 3 11:14:16 CEST 2015


Hi

I cannot test it in absence of data. Anyway I would not use saving single objects but use list instead.

Something like

lll <- vector(mode="list", nrow(met))

for (i in 1:nrow(met)) {
form <- as.formula(paste(met[i], "~ egfr_v1_ckdepi+pc1+pc2+pc3+V1AGE01+GENDER"))
lll[i] <- Scores(Z=metalofGT,formula=form)
}

Cheers
Petr


> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Lida
> Zeighami
> Sent: Thursday, July 02, 2015 6:48 PM
> To: r-help at r-project.org
> Subject: Re: [R] question
>
> Thank you so much for replying me!
> for better understanding my problem, I explain my problem more:
>
> I have a 682*1 matrix called "met" , the first 5 rows similar below:
>
> >  rownames(met)[1:5]
>
> [1]  "glycine_imp"
> [2]  "Nacetylglycine_imp"
> [3]  "sarcosine_imp"
> [4]  "dimethylglycine_imp"
> [5]  "betaine_imp"
>
> and I have a function in R that each time use one of the row names of
> "met"
> matrix and create a new object file and I should save the objects!
>
> my function is  "
> Scores(Z=metalofGT,formula="met[i]~egfr_v1_ckdepi+pc1+pc2+pc3+V1AGE01+G
> ENDER")
> " that each time just I should change the met[i] and replace by row
> names
> "met" one by one and for each of them I should rename the function and
> after that I should save each object!
> for example for first row of "met" I have
>
> >   prep1<-
> Scores(Z=metalofGT,formula="glycine_imp~egfr_v1_ckdepi+pc1+pc2+pc3+V1AG
> E01+GENDER")
> #creat the object file for first row and called prep1###
>
> >   save(prep1, file="prep1.RData", compress="bzip2")      ##save the
> object file as "prep1.RData"#####
>
> I should do this process for 682 row names of "met" matrix and at the
> end I
> should have    "prep1.RData"  ,   "prep2.RData"   , "prep3.RData"
>
> so, would you please help me how to do it?
>
> Many Thanks,
> Ati
>
> On Wed, Jul 1, 2015 at 1:07 PM, Lida Zeighami <lid.zigh at gmail.com>
> wrote:
>
> > I have 682 variables in a data frame , and a function that  I should
> feed
> > 682 variables in this function one by one and each time save the file
> as a
> > special name!
> > for emaple:
> > my data frame file includes 682 names :
> > 1  aaa
> > 2  bbb
> > 3  dfdsfg
> > 4 fghh
> > .
> >
> > 682 fgfhg
> > and a function like prep(Z, aaa, .....) and each time I should change
> the
> > variable name in this function and read the variable from the data
> frame
> > and each time I should save the file as a special name such as:
> >
> > prep1<- prep(z, aaa,...)
> > prep2<- prep(z, bbb,...)
> > prep3<- prep(z, dfdsfg,..)
> > Prep4<- prep(z, fghh,...)
> >
> > How can I use loop function in R to that?
> >
> > Thanks
> >
>
>       [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.


More information about the R-help mailing list