[R] Using a loop to define new variables
Ivan Calandra
ivan.calandra at uni-hamburg.de
Fri May 28 14:05:30 CEST 2010
Hi,
Would this do:
test <- data.frame(a=LETTERS[1:10], x=1:10, y=seq(0.1,1,0.1)) #create
some data.frame
test$z <- test$x/test$y #add a column
?
HTH,
Ivan
Le 5/28/2010 13:52, Andre Easom a écrit :
> Hi,
>
> I'm a novice R user, much more used to SAS. My problem is pretty simple - basically, in a data frame, I have variables named
> x1,....,x10 and y1,...,y10; and I would like to create r1 = x1 / y1 etc
>
> Apologies if this is way too rudimentary - but I couldn't find any posts online which solve this exact issue.
>
> Cheers,
> Andre
> **********************************************************************
> This email and any attachments are confidential, protect...{{dropped:22}}
>
> ______________________________________________
> 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.
>
>
--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de
**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php
More information about the R-help
mailing list