Re: [R] data frame

From: justin bem <justin_bem_at_yahoo.fr>
Date: Mon 26 Dec 2005 - 07:36:22 EST

  

R-help@stat.math.ethz.ch   

Rhett Eckstein <glaxowell@gmail.com> a écrit : 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

Thanks for any help !!

  see about NA/na/...     

  in s4.2 do something like s4.2[1:2]<-NA



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html                 

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Dec 26 07:46:25 2005

This archive was generated by hypermail 2.1.8 : Mon 26 Dec 2005 - 14:32:47 EST