I am an early user of Rstudio, and i have a quite simple problem, but unfortunately i am not able to solve it. I just want to aggregate rows of my data.frame by words contained on the first column of the df. The data.frame is made by five columns: The first one is made by words; the second, the third, the fourth, the fifth ones are made by numeric values.
for example if the data would be:
SecondWord X Y Z Q
NO 1 2 2 1
NO 0 0 1 0
YES 1 1 1 1
i expect to see a result like:
SecondWord X Y Z Q
NO 1 2 3 1
YES 1 1 1 1
How could i do? i have tried to use the following method:
test <- read.csv2("test.csv")
df<-aggregate(.~Secondword,data=test, FUN = sum, na.rm=TRUE)
But the values were not the ones i expected to see. Thank you for your future helps and sorry for the "simple" question.