Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Some R code to demo boxplots, beanplots, pirateplots, etc
- library(psych)
- library(dplyr)
- library(tidyr)
- library(beanplot)
- library(yarrr)
- # Load the cushny data
- data(cushny)
- # Plot it using error.bars. Following example in psych package manual
- error.bars(cushny[1:4],
- within=TRUE,
- ylab="Hours of sleep",
- xlab="Drug condition",
- main="95% confidence of within subject effects")
- # Reformat the data into a "long" and "tidy" format
- Df <- select(cushny, Control, drug1, drug2L, drug2R) %>%
- mutate(subject = factor(seq(length(Control)))) %>%
- select(subject, everything()) %>%
- gather(drug, sleep, Control:drug2R) %>%
- arrange(subject)
- # A box plot
- boxplot(sleep ~ drug,
- data=Df,
- ylab='Hours of sleep',
- xlab='Drug')
- # Beanplot
- beanplot(sleep ~ drug,
- data=Df,
- ylab='Hours of sleep',
- xlab='Drug',
- col='lightgray',
- overallline = 'median')
- # Pirateplot
- pirateplot(formula = sleep ~ drug,
- data = Df,
- theme = 3,
- point.o = 1,
- ylab='Hours of sleep',
- xlab='Drug')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement