Re: [R] loop

From: Neuer Arkadasch <neuer_arkadasch_at_yahoo.de>
Date: Wed, 05 Mar 2008 18:04:35 +0100 (CET)


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)

-----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. Received on Wed 05 Mar 2008 - 17:32:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Mar 2008 - 14:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive