JASP doesn't compute mean of multiple variables in new column
Hey there,
I need to compute the mean of multiple variables(/columns) as a new variable in JASP, but I can't get it to work.
I've tried to do it via R code by putting in: (var1 + var2 + var3) / 3 for example, but don't get any output (no error message either though).
I've also tried using the dataframe method: apply(data.frame(var1, var2, var3), 1, mean, na.rm=TRUE)
or the drag&drop feature, both with the same result.
I suspect that the reason is that var1, var2 and var3 don't have numeric values in their columns. Instead they have the scale labels used in the questionnaire, i.e. "Strongly disagree [1]", "[2]" ... "Strongly agree [5]". So I suspect that JASP doesn't read the numeric values that are behind those labels for some reason.
Is there anything I can do about that? Or might there be a different reason, that I haven't thought of yet?
Thank you and best regards
Comments
using R code you can do:
I would go to Excel, then use and IF column to transform the vars 1, 2 & 3, and then the AVERAGE in a new column. Then save in .csv and open with JASP. Or save in the same .csv file and then JASP will update the data file you have already open.
@patc3
Thank you! This >almost< does it correctly. Because in my case it uses the wrong values for each row. For example: Instead of the value 5 for "Strongly agree [5]", it uses the value 6. So I used a workaround by doing:
((cbind(var1) - 1) + (cbind(var2) - 1) + (cbind(var3) - 1) /3
So cbind gives me numerical values for each column, which I then correct with -1.
However, I assume that that's not the intended purpose of the cbind command. Is there a different command which was only designed to output the numerical values behind the aforementioned labels?
I don't want to introduce errors in my data down the line by using a function that is actually supposed to do something else than what I intend.
@gvleiroas
Thank you! Will try that as well.