[R] data frame
Sean Davis
sdavis2 at mail.nih.gov
Thu Dec 22 15:21:45 CET 2005
On 12/22/05 9:11 AM, "Rhett Eckstein" <glaxowell at gmail.com> wrote:
> Dear R users:
>
>> s4 <- seq(length=10, from=1, by=5)
>> s<-data.frame(s4,s4,s4)
> I would like to do some modification to s.
> And I want the form like the following,if it is possible, how should I do?
> The last column is the sum of previous three column.
> s4 s4.1 s4.2 sum
> 1 1 1
> 2 6 6
> 3 11 1 12
> 4 16 6 22
> 5 21 11 1 33
> 6 26 16 6 48
> 7 31 21 11 63
> 8 36 26 16 78
> 9 41 31 21 93
> 10 46 36 26 108
Rhett,
You might want to look at ?embed. It would need some modification, but you
can hopefully get the idea.
embed(s4,3)
Sean
More information about the R-help
mailing list