[Lego Report] Accuracy as a function of Condition
3 posters
Cognitive Semiotics :: Tools :: R
Page 1 of 1
[Lego Report] Accuracy as a function of Condition
Note that I've named my dataframe (where all the data is located) "AllData", remember to replace it with whatever you've called your own dataframe
To get the graph:
Which gives you a bar-graph depicting the distribution of correct/incorrect answers, divided between Individual and Collective conditions.
Because I wasn't able to get R to pay attention, I opted to go a slightly different route and calculate the percentages myself, as I couldn't get R to implement the percentages on the graph itself for the sake of clarity and accuracy.
To do this, you can assign all values of a specific condition to a new dataframe:
This creates 2 new dataframes by telling R to move all values that are not Collective (m) or Individual (n) into a new box, splitting the two so we can more easily get a good look at them seperately.
Just to clarify:
"m" has all the individual condition results (because the code specifies '!="Collective"', or in good ol' English, "Not equal to Collective"
"n" has the reverse, obviously.
You can then do a summary of the new sets, giving you the amount of answers:
Keep in mind we only want to see the values relating to Accuracy, so to avoid it throwing everything it has at us, we add in "$Accuracy==1", telling it to show us the subset Accuracy, and how many of them are correct(1), i.e. TRUE = Correct, FALSE = Incorrect.
It returns (for "m", Individual):
Mode FALSE TRUE NA's
logical 2065 1295 304
And with that, we can calculate the percentage, excluding NA values:
That is:
> FALSE+TRUE
= TOTAL
> TRUE/TOTAL*100
= PERCENT TRUE
To get the graph:
ggplot(AllData, aes(x=Accuracy==1, fill=Condition)) + geom_bar(position="dodge")
Which gives you a bar-graph depicting the distribution of correct/incorrect answers, divided between Individual and Collective conditions.
Because I wasn't able to get R to pay attention, I opted to go a slightly different route and calculate the percentages myself, as I couldn't get R to implement the percentages on the graph itself for the sake of clarity and accuracy.
To do this, you can assign all values of a specific condition to a new dataframe:
> m <- AllData[AllData$Condition!="Collective",]
> n <- AllData[AllData$Condition!="Individual",]
This creates 2 new dataframes by telling R to move all values that are not Collective (m) or Individual (n) into a new box, splitting the two so we can more easily get a good look at them seperately.
Just to clarify:
"m" has all the individual condition results (because the code specifies '!="Collective"', or in good ol' English, "Not equal to Collective"
"n" has the reverse, obviously.
You can then do a summary of the new sets, giving you the amount of answers:
> summary(m$Accuracy==1)
> summary(n$Accuracy==1)
Keep in mind we only want to see the values relating to Accuracy, so to avoid it throwing everything it has at us, we add in "$Accuracy==1", telling it to show us the subset Accuracy, and how many of them are correct(1), i.e. TRUE = Correct, FALSE = Incorrect.
It returns (for "m", Individual):
Mode FALSE TRUE NA's
logical 2065 1295 304
And with that, we can calculate the percentage, excluding NA values:
> 2065+1295
[1] 3360
> 1295/3360*100
[1] 38.54167
That is:
> FALSE+TRUE
= TOTAL
> TRUE/TOTAL*100
= PERCENT TRUE
Santiak- Admin
- Posts : 23
Join date : 2016-02-24
Re: [Lego Report] Accuracy as a function of Condition
Thanks! In addition to the latest post this is worth its weight in gold (good this is virtual data cause i dont have any gold to give you). Thanks for putting all this up!
tobi-wan kenobi- Posts : 7
Join date : 2016-03-10
Re: [Lego Report] Accuracy as a function of Condition
MADS our hero!
" />
" />
alinemeret- Posts : 4
Join date : 2016-03-02
Cognitive Semiotics :: Tools :: R
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum