I interpret emotional intelligence scores for a living, and part of my analysis involves looking at differences of 10 or more points between scores. To do this more easily, I created the following function in r:
eqi_function <- function(x) {
for(i in x) {
i <- abs(i - x[1:15])
print(i)
}
}
In this function, x is a vector of 15 scores, e.g.:
test.scores <- c(112,122,122,98,101,106,106,116,100,123,123,122,122,115,115)
When I call my function using this vector of test scores, here's the output:
[1] 0 10 10 14 11 6 6 4 12 11 11 10 10 3 3
[1] 10 0 0 24 21 16 16 6 22 1 1 0 0 7 7
[1] 10 0 0 24 21 16 16 6 22 1 1 0 0 7 7
[1] 14 24 24 0 3 8 8 18 2 25 25 24 24 17 17
[1] 11 21 21 3 0 5 5 15 1 22 22 21 21 14 14
[1] 6 16 16 8 5 0 0 10 6 17 17 16 16 9 9
[1] 6 16 16 8 5 0 0 10 6 17 17 16 16 9 9
[1] 4 6 6 18 15 10 10 0 16 7 7 6 6 1 1
[1] 12 22 22 2 1 6 6 16 0 23 23 22 22 15 15
[1] 11 1 1 25 22 17 17 7 23 0 0 1 1 8 8
[1] 11 1 1 25 22 17 17 7 23 0 0 1 1 8 8
[1] 10 0 0 24 21 16 16 6 22 1 1 0 0 7 7
[1] 10 0 0 24 21 16 16 6 22 1 1 0 0 7 7
[1] 3 7 7 17 14 9 9 1 15 8 8 7 7 0 0
[1] 3 7 7 17 14 9 9 1 15 8 8 7 7 0 0
I would like to copy and paste this output into Excel and use conditional formatting to highlight cells with a difference of 10 or more points.
I've tried countless functions (e.g., write_clip, write. Table) and I've also tried changing my function to print (i) as a table, as a matrix, and as a dataframe, which doesn't create this output. Writing it into a csv. isn't working for me either and I'm not sure what I'm doing wrong.
If you think there's a better method for producing the results I am looking for, including changing the function, let me know. I've only been using r for about 2 months now! :-)
Appreciate your suggestions, insight, and expertise. - Tamara