[R] change values in data frames

poul morteterre at infonie.fr
Fri Jun 27 11:17:42 CEST 2008


Hello every body,
I am quite a new user of R so I beg your pardon for this naive question and
the lake of syntax with wich I ask it:

I have a data frames like this:

cola	colb
1	c
1	i
1	i
1	c
2	i
2	c
2	c
2	i
2	i
...
10000

I would like ,for each level of cola and for x in colb:

-if colb[x]=="i" and colb[x-1] does not exist (first row in dataframes),
then replace colb[x] by "l"
-if colb[x]=="i" and colb[x-1]=="c" (previous row in data frmes), then
replace colb[x] by "l"
-if colb[x]=="i" and colb[x-1]=="i" (previous row in data frmes), then
replace colb[x] by "h"

Thanks in advance

Paul

-- 
View this message in context: http://www.nabble.com/change-values-in-data-frames-tp18151205p18151205.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list