[R] Difference beetwen element in the same column
David Winsemius
dwinsemius at comcast.net
Thu Jun 18 00:06:21 CEST 2009
tdf <- read.table(textConnection("pressure , k , eps , zeta , f ,
velocity0 , velocity1 , velocity2 , vtkValidPointMask ,
PointCoordinates0 , PointCoordinates1 , PointCoordinates2\n
0.150545 , 0.000575811 , 0.0231277, 0.000339049, -0.0193008,
0.00318629, -6.24066e-07, 5.39599e-05, A, 7, 0, 0, 0\n
0.150546, 0.000782719, 0.0226157, 0.000497957, -0.0192084, 0.00367781,
5.09813e-06, 5.90689e-05, A, , .0003035, 0.000225, 1\n
0.056182, 0.00501745, 0.022044, 0.00919293, -0.040201, 0.232017,
3.84469e-06, 4.93005e-06, A, 7, 3.0347, 2.24977, 9999\n
0.0561819, 0.00475808, 0.0218272, 0.00853701, -0.0412128, 0.227424,
3.23064e-07, 4.8063e-06, A, 7, 3.035, 2.25, 10000\n"), header=TRUE,
sep=",", as.is=TRUE)
> y <- diff(tdf$PointCoordinates1)[c(1,3)]
> y
[1] 0.000225 0.000230
On Jun 17, 2009, at 5:43 PM, Carletto Rossi wrote:
> Hi, i have this file
>
> pressure,k,eps,zeta,f,velocity:0,velocity:1,velocity:
> 2,vtkValidPointMask,Point
> Coordinates:0,Point Coordinates:1,Point Coordinates:
> 2,vtkOriginalIndices
> 0.150545,0.000575811,0.0231277,0.000339049
> ,-0.0193008,0.00318629,-6.24066e-07,5.39599e-05,^A,7,0,0,0
> 0.150546,0.000782719,0.0226157,0.000497957
> ,-0.0192084,0.00367781,5.09813e-06,5.90689e-05,^A,
> 7,0.0003035,0.000225,1
> 0.056182,0.00501745,0.022044,0.00919293
> ,-0.040201,0.232017,3.84469e-06,4.93005e-06,^A,7,3.0347,2.24977,9999
> 0.0561819,0.00475808,0.0218272,0.00853701
> ,-0.0412128,0.227424,3.23064e-07,4.8063e-06,^A,7,3.035,2.25,10000
>
>
> I have to compute the difference beetwen the Second Element in Point
> Coordinates:1 column and the First Element in Point Coordinates:1
>
> 0.0003035 - 0
>
> and the difference beetwen the Fourth Element in Point Coordinates:1
> column
> and the Third Element in Point Coordinates:
>
> 3.035 - 3.0347
>
> and i'd like to put this two results in a new variable named y
>
> in what way i can do that?
>
> [[alternative HTML version deleted]]
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list