[R] XYZ data

arun smartpink111 at yahoo.com
Wed Jun 26 18:51:18 CEST 2013


Hi,
Not sure whether there is any pattern in adding the small number.
dat1<- read.table(text="
X              Y                 Z
15                               20                              30
15                               20                              40
",sep="",header=TRUE)
dat1[,1:2]<-do.call(rbind,lapply(seq_len(nrow(dat1)),function(i) dat1[i,1:2]+0.00001*i) )
dat1
#         X        Y  Z
#1 15.00001 20.00001 30
#2 15.00002 20.00002 40

A.K.



I have x, y, z data. The x, y fields dont change but Z does. How do I add a 
very small number onto the end of each x, y data point. 

For example: 

Original (X)              Original (Y)                 Original (Z) 
15                               20                              30 
15                               20                              40 




New (X)              New (Y)                 New (Z) 
15.00001             20.000001              30 
15.00002             20.000002              40 


Thanks 
-- 
Shane 




More information about the R-help mailing list