[R] Difference beetwen element in the same column

0 views
Skip to first unread message

Carletto Rossi

unread,
Jun 17, 2009, 5:43:48 PM6/17/09
to r-h...@r-project.org
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]]

______________________________________________
R-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Carletto Rossi

unread,
Jun 17, 2009, 5:49:56 PM6/17/09
to r-h...@r-project.org
my goal is to compute this variable

tauw = 0.00095* velocity:0 (of the second row: 0.00367781) / (0.0003035 - 0)

and

tauw1 = 0.00095* velocity:0 (of the third row : 0.232017) / (0.0003035 - 0)

and put tauw e tauw1 in a new variable

2009/6/17 Carletto Rossi <nuov...@gmail.com>

David Winsemius

unread,
Jun 17, 2009, 6:06:21 PM6/17/09
to Carletto Rossi, r-h...@r-project.org
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

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

David Winsemius

unread,
Jun 17, 2009, 6:10:09 PM6/17/09
to Carletto Rossi, r-h...@r-project.org

On Jun 17, 2009, at 5:49 PM, Carletto Rossi wrote:

> my goal is to compute this variable
>
> tauw = 0.00095* velocity:0 (of the second row: 0.00367781) /
> (0.0003035 - 0)

I'm sorry, you have exceeded your daily quota of homework help. Read
some introductory material and come back after you know what a valid
object name is in R, and when you do, bring with you a dataset that
does not require extensive editing for input and has the same number
of items in the headers as there are items per line.

>
> and
>
> tauw1 = 0.00095* velocity:0 (of the third row : 0.232017) /
> (0.0003035 - 0)
>
> and put tauw e tauw1 in a new variable
>
>
>
> 2009/6/17 Carletto Rossi <nuov...@gmail.com>
>
>> 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]]
>
> ______________________________________________
> R-h...@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD


Heritage Laboratories
West Hartford, CT

______________________________________________

Reply all
Reply to author
Forward
0 new messages