Main content

R Data analyses

Menu

Loading wiki pages...

View
Wiki Version:
@[toc](Sections) ### Basics Great, now we know how to collect data. But how do you access data? Ibex simply generates a file called *results* under the project's folder named... *results*. It is a simple CSV file (with lots of comment lines, starting with `#`) which makes it very easy to load in R. ### Loading the *results* file in R ```R # To summarize the data (see %>% commands below) require("dplyr") # The fields are separated by commas # There are comment lines starting with # (useless for analyses) # There is no header (no single line assigning each column a name) results_full <- read.csv("results", sep=",", comment.char="#", header=F) # As we can see, the columns have default Vn names head(results_full) # The 7 first columns (until IbexGroup) are not particularly relevant # The 8 last columns (starting from Parameter) contain all we need for our analyses colnames(results_full) <- c("SendResultsTime", "MD5IP", "IbexController", "IbexItemNum", "IbexElementNum", "IbexLabel", "IbexGroup", "Parameter", "Value", "Time", "Comment", "ID", "Label", "Item", "Group") ``` ### Subsetting to trials ```python # Parameter == "answer" means a response line for the element we labeled 'answer' (our scale) results_answer_ratings <- results_full %>% filter(Label == "rating" & Parameter == "answer") # Parameter == "alternative" means a response line for the element we labeled 'alternative' (our input box) results_answer_inputs <- results_full %>% filter(Label == "input" & Parameter == "alternative") ``` ### Taking a quick look at the data ```python # Let's take a look at all the alternatives that were proposed for each item results_answer_inputs %>% group_by(Item, Value) %>% summarize( n = n() ) # Let's see how 'any' vs 'either' impacted perception of naturalness results_answer_ratings %>% group_by(Group) %>% summarise( n = n(), score = mean( as.numeric(as.character(Value)) ) ) # Let's look at whether 'any' vs 'either' influenced rate of antonymic alternatives results_answer_inputs %>% mutate(dry = grepl("dry", Value), cold = grepl("cold", Value)) %>% group_by(Group, Item) %>% summarise( dry = sum(dry), cold = sum(cold) ) ``` ### Comparing two lines (= two measures) for the same trial ```python # Were people faster to score in the 'any' or the 'either' group? results_RT_per_item_per_ppt <- results_full %>% filter(Label == "rating" & (Parameter == "answer" | Value == "RunFirstInstruction" )) %>% group_by(Item, ID) %>% summarize( Group = unique(Group), difference = diff(as.numeric(as.character(Time))) ) results_RT_per_group <- results_RT_per_item_per_ppt %>% group_by(Group) %>% summarize( meanRT = mean(difference) ) ``` ### Saving simplified table for manual edits ```R # Let's save a smaller table so we can manually treat the alternatives in a spreadsheet editor results_simplified <- results_full %>% select(Parameter:Group) %>% filter(Parameter != "Page") write.csv(results_simplified, "results_simplified.csv") ``` [1]: https://osf.io/9trsx/wiki/Recruitment%20&%20Data%20collection/ [2]: https://osf.io/9trsx/wiki/Preloading%20Resources/
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

Start managing your projects on the OSF today.

Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.