I have some data that I am not sure how bet to analyze. It is currently in Excel and will need to fiddling to get to work in R, I am sure. I have a set of targets, their sizes and color. I also have users, the condition and their score for each target.
So the first table look like this:
Target, 1, 2, 3, 4, 5 ...
Size, L, M, L, S, L ...
Color R, B, G, B, R ...
Then I have all the user data that has a column for the user id, a column for the device, then a column for the score on each target.
User, Condition, 1, 2, 3, ...
1 A 5, 2, 8, ...
1 D 2, 4, 6, ...
2 A 1, 4, 6, ...
2 B 5, 8, 3, ...
I mainly want to run an ANOVA between the 4 conditions so see if the mean scores are the same on L targets, or R targets for example.
I have never had to use a 2nd table to filter or look up data like this. How do I do this?
Quick and dirty solution (because I believe someone will certainly propose a more elegant solution avoiding loop):
I am assuming you are able to import your data into R, but you may want to adapt the above code if the data structure isn’t the one you show in your excerpt. Basically, the idea is to consider your
Targetcode as a way to indexSizeandColorlevels, which we need in the finaldata.framefor each repeated measurement (on the ith subject).The updated
data.framelooks like:From there, you can perform a 3-way ANOVA or study specific contrasts.