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.Names = c("Q1",
"Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9", "Q10", "Q11",
"Q12", "Q13", "Q14", "Q15", "Q16", "Q17", "Q18", "Q19", "Q20",
"Q21"), row.names = c(NA, 6L), class = "data.frame")
What I need new is to create another table by using this table columns. It must have the follow structure: Column A values come from mean of columns Q1 and Q11 Column B values come from mean of columns Q10 and Q21
The final result is expected to be:
A B
1 5.5 6
2 6 6
3 4.5 4.5
4 5.5 7
5 6 7
6 5 7
To help you understand, the calculation is:
1A = (6 + 5) / 2
1B = (6 + 6) / 2
And so on...
Is there a fuction I can use to do this?
I thought this one would do the trick, but I was mistaken...
> c(mean(c(TiposMotivA$Q1,TiposMotivA$Q11)),mean(c(TiposMotivA$Q11,TiposMotivA$Q21)))
[1] 5.645161 6.395161
But instead of calculating mean for each row it took mean from all values in each row and then calculated the mean. Then I tried this:
Teste$A <- tapply(TiposMotivA$Q1,TiposMotivA$Q11,mean)
Teste$B <- tapply(TiposMotivA$Q10,TiposMotivA$Q21,mean)
No success again... I know I must be far from what I need, so I ask for help... Any clues are gonna be very appreciated!