Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. # Create a data frame for illustration purposes
  2. df <- data.frame(period = rep(1:10, 3),
  3. group = rep(LETTERS[1:3], each = 10),
  4. value = sample(100, 30, replace = TRUE))
  5.  
  6. df$exp.value = exp(df$value)
  7.  
  8. # Split dataframe by group
  9. df_split <- split(df, df$group)
  10.  
  11. # Plots of values in each group
  12. plots <- lapply(df_split, function(i){
  13. ggplot(data = i, aes(x = period, y = value)) + geom_line()
  14. })
  15.  
  16. # Plots of logged values in each group
  17. plots_exp <- lapply(df_split, function(i){
  18. ggplot(data = i, aes(x = period, y = exp.value)) + geom_line()
  19. })
  20.  
  21. multiplot(plots[[1]], plots_log[[1]], cols = 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement