I'm trying to manually reorder the y-axis on the plot below to go in order from P1 to P30. I tried to change the levels in the dataframe itself, but I got an error saying:
'Error in eval(substitute(expr), e) : argument is missing, with no default'
Is there another way to reorder the y-axis so that I can avoid this error?
Here is my code for the dataframe and the plot:
#subsetting the data
P_all_indie =
P_all_nonames %>%
group_by(participant, stimuli, condition) %>%
summarize(indie_mean = mean(trial_resp.keys))
P_speeded_indie =
P_all_indie %>%
filter(condition == "speeded")
#attempting to order the y-axis variable
P_speeded_indie = within(P_speeded_indie, participant = factor(participant, levels = c('P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10',
'P11', 'P12', 'P13', 'P14', 'P15', 'P16', 'P17', 'P18', 'P19', 'P20',
'P21', 'P22', 'P23', 'P24', 'P25', 'P26', 'P27', 'P28', 'P29', 'P30')))
#got this error:
#'Error in eval(substitute(expr), e) : argument is missing, with no default'
#plotting
ggplot(P_speeded_indie, mapping = aes(x = indie_mean, y = participant)) +
geom_density_ridges() +
ggtitle('Average Individual Responses to Stimuli (Speeded)') +
ylab('Participant') +
xlab('Mean Rating per Stimulus') +
scale_color_discrete(name = "Condition") +
theme(legend.position = "none")[![enter image description here][1]][1]