Message-ID: <OF78A1DD8B.F42F2B62-ONC1257404.004A068B-C1257404.004A31C0@precheza.cz>
Date: 2008-03-06T13:30:35Z
From: PIKAL Petr
Subject: loop
In-Reply-To: <797668.61399.qm@web25815.mail.ukl.yahoo.com>
Hi
r-help-bounces at r-project.org napsal dne 05.03.2008 18:04:35:
> Thank you Yinghai, that's what I need :-)!
>
> Yinghai Deng <yinghai.deng at bri.nrc.ca> schrieb: m <- seq(-1,1,0.1)
> x1 <- c()
> x2 <- c()
> for(i in 1:length(m)){
> x1[i] <- m[i]
> x2[i] <- m[i]^2
> }
> dat <- data.frame(x1,x2)
The same result you will get by
dat2<-data.frame(x1=m, x2=m^2)
> all.equal(dat,dat2)
[1] TRUE
Regards
Petr
>
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org]On Behalf Of Neuer Arkadasch
> Sent: March 5, 2008 10:00 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] loop
>
>
> Hello all,
>
> I am trying to use
>
> m <- seq(-1,1,0.1)
> x1 <- vector()
> x2 <- vector()
> for(i in m){
> x1[i] <- i
> x2[i] <- i^2
> }
> dat <- data.frame(x1,x2)
> But, I have false result
> >dat
> x1 x2
> 1 1 1
>
> could some tell me how it is possible to do this?
>
> Thank you!
>
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>
>
>
> ---------------------------------
> Lesen Sie Ihre E-Mails jetzt einfach von unterwegs..
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.