[R] create data set from selection of rows

e-letter inpost at gmail.com
Thu Mar 17 11:50:19 CET 2011


On 15/03/2011, Francisco Gochez <fjgochez at googlemail.com> wrote:
> Hi,
>
> What you are after is:
>
> datasubset <- dataset[ dataset[,3] == "text3", ]

Thank you. For the set

text1,23,text2,45
text1,23,text3,78
text1,23,text3,56
text1,23,text2,45

Is it possible to write a function that selects rows containing
'text3' and applies the function 'sum' to values '78' and '56'? The
control statements described in the document 'an introduction to r'
(Venables and Smith, 2010) suggest that the if statement would return
'true', to prevent a sum function being applied to 'true' results.



More information about the R-help mailing list