Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.65 KB | None | 0 0
  1. df <- data.frame(treatment = c(rep(c("Stimulation", "Control"), 8)),
  2.                  group = c(rep(c("A", "B"), 4),
  3.                            rep(c("B", "A"), 4)),
  4.                  value = rnorm(16, mean = 150, sd = 20),
  5.                  units = rep(c("u/min", "lit"), 8))
  6.  
  7.  
  8. re <- list(A = list(Stimulation = "297.00 ± 19.86", Control = "304.44 ± 14.96"),
  9.            B = list(Stimulation = "4.51 ± 0.07", Control = "4.55 ± 0.10"))
  10.  
  11. add_unit <- function(list, u){
  12.   z <- lapply(list, function(x){
  13.     list(
  14.       Stimulation = paste(x$Stimulation, unique(u)),
  15.       Control = paste(x$Control, unique(u)))
  16.   })
  17. }
  18.  
  19. a <- add_unit(re, u = df$units)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement