Try this: m <- seq(-1,1,0.1) x1 <- vector(length=length(m)) x2 <- vector(length=length(m)) for(i in m){ x1[i] <- i x2[i] <- i^2 } dat <- data.frame(x1,x2)
Ravi. ---------------------------------------------------------------------------- ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html ---------------------------------------------------------------------------- -------- -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neuer Arkadasch Sent: Wednesday, March 05, 2008 10:00 AM To: [EMAIL PROTECTED] 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@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.