[R] Differenciate numbers from reference for rows
M.Ribeiro
mresendeufv at yahoo.com.br
Sat Oct 30 00:54:15 CEST 2010
So, I am having a tricky reference file to extract information from.
The format of the file is
x 1 + 4 * 3 + 5 + 6 + 11 * 0.5
So, the elements that are not being multiplied (1, 5 and 6) and the elements
before the multiplication sign (4 and 11) means actually the reference for
the row in a matrix where I need to extract the element from.
The numbers after the multiplication sign are regular numbers
Ex:
> x<-matrix(20:35)
> x
[,1]
[1,] 20
[2,] 21
[3,] 22
[4,] 23
[5,] 24
[6,] 25
[7,] 26
[8,] 27
[9,] 28
[10,] 29
[11,] 30
[12,] 31
[13,] 32
[14,] 33
[15,] 34
[16,] 35
I would like to read the rows 1,4,5,6 and 11 and sum then. However the
numbers in the elements row 4 and 11 are multiplied by 3 and 0.5
So it would be
20 + 23 * 3 + 24 + 25 + 30 * 0.5.
And I have this format in different files so I can't do all by hand.
Can anybody help me with a script that can differentiate this?
Thanks
--
View this message in context: http://r.789695.n4.nabble.com/Differenciate-numbers-from-reference-for-rows-tp3019853p3019853.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list