I have a dataframe, with 4 groups of grades of students in one column, and the responses of a question in other column. I am using the split function to create a boxplot and, after, to test the groups. I want to create only two groups (merging the 2 lowest groups and the 2 highest). However, I am struggling with that. The split function gives a dataframe, a matrix, vectors?
df <- data.frame(
groups = c("group 1", "group 2", "group 3", "group 4", "group 1", "group 2", "group 3", "group 4"),
responses = c(1, 4, 5, 9, 3, 4, 6, 9)
)
splittedDF <- split(x = df$responses, f = df$groups)
THis gives this output:
$`group 1`
[1] 1 3
$`group 2`
[1] 4 4
$`group 3`
[1] 5 6
$`group 4`
[1] 9 9
And I want to merge to something like this:
$`Lowest groups`
[1] 1 3 4 4
$`Highest groups`
[1] 5 6 9 9
DO you have some ideas?