Comments

Comment

Visitor
Avatar
This was very helpful, thanks for the excellent article! Would there be a way to use a continuous variable as a factor in order to group the data, but as a numeric when positioning/plotting the data?

For example, could you still plot the results at Dose=0.5, 1, and 2 separately but position the box plots along the x axis such that Dose=1 and Dose=2 are twice as far apart as Dose=0.5 and Dose=1?

Comment

Administrator
Avatar
To treat x-axis as continuous variable,

1. D'ont convert "dose" to a factor variable
2. Specify the argument group = dose

Code R :
 
ggplot(ToothGrowth, aes(dose, len, group = dose)) +
  geom_boxplot()