[R] converting a summary table to survey database form

Pancho Mulongeni p.mulongeni at namibia.pharmaccess.org
Thu Aug 22 18:08:38 CEST 2013


Hi!
I am looking to choose a condom based on its pleasure score.
I received some summarised data from 10 individuals:
structure(list(Ramses = c(4, 4, 5, 5, 6, 3, 4, 4, 3, 4), Sheiks = c(5, 
5, 6, 4, 7, 6, 4, 5, 6, 3), Trojans = c(7, 8, 7, 9, 6, 3, 2, 
2, 2, 3), Unnamed = c(2, 1, 1, 3, 3, 4, 5, 4, 4, 3)), .Names = c("Ramses", 
"Sheiks", "Trojans", "Unnamed"), row.names = c(NA, 10L), class = "data.frame")

However to do an annova to see if the mean score is not the same for all brands, I understand I need to have the data in survey database form i.e.
1 Ramses 4
1 Sheiks 4
1 Trojans 7
1 Unamed 2
2 Ramses 4
...
10 Unamed 3

I would have a dataframe with two factor 'brand' and 'score'. I would then do an aov(score~brand,data=condom.dataframe) for instance.

However to get my original condomData which has the tabulated scores per brand into the summarised form is a pain. 
I tried to just get a vector that essentially has all the rows of condomData put into one long vector from i.e. c( a1_1,a1_2...a1_5,a2_1,2_..a2_5.......a10_5)
I would then bind this together with a names vector of rep(c('Ramses','Sheiks','Trojans','Unamed),10) and I would have my desired datafram for anova.
But alas my attempt below does not work:
r<-dim(condomData)[1]
scoreS<-c()
for (i in 1:r) {
score<-as.numeric(condomData[r,])
scoreS<-c(scoreS,s)
}
 It just gives me the last row of condomData copied 10 times.
 Any help? 
Thank you, I really want to know if all condoms are equal.

Pancho Mulongeni
Research Assistant
PharmAccess Foundation
1 Fouché Street
Windhoek West
Windhoek
Namibia
 
Tel:   +264 61 419 000
Fax:  +264 61 419 001/2
Mob: +264 81 4456 286



More information about the R-help mailing list