Skip to content

Instantly share code, notes, and snippets.

@markdly
Last active May 23, 2018 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markdly/a89e4e787ca4e5d8b124d0945d1c7725 to your computer and use it in GitHub Desktop.
Save markdly/a89e4e787ca4e5d8b124d0945d1c7725 to your computer and use it in GitHub Desktop.

Does this do what you need?

#data for Paper
Paper <- c(1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9 )

#data for selectedES.prepost
selectedES.prepost <- c(0.0048, -0.1420, -0.3044, -1.3024, -0.4052, -0.6066, -0.1961, -1.1187, -0.4585, -0.8251, -0.5328, -1.3623, -0.5450, -0.4982, -0.5714, -0.8793, -0.3677, -0.3976, -0.6136, -0.7047, -0.8580, -0.5024, -0.8018, -0.8927, -0.3106, -0.5893, -0.6677, -1.6663, -1.1769, -0.8384, -0.5632, -0.5237, -0.3458, -0.9957, -0.5331, -0.7413, -0.0311, -0.4936, 0.5422, -0.0340)

#creating a test dataset
mydata <- data.frame(Paper, selectedES.prepost)

library(tidyverse)
mydata %>% 
  group_by(Paper) %>% 
  summarise(average = mean(selectedES.prepost))
#> # A tibble: 9 x 2
#>   Paper  average
#>   <dbl>    <dbl>
#> 1     1 -0.509  
#> 2     2 -0.458  
#> 3     3 -0.907  
#> 4     4 -0.572  
#> 5     5 -0.659  
#> 6     6 -0.668  
#> 7     7 -0.852  
#> 8     8 -0.575  
#> 9     9  0.00487

Created on 2018-05-23 by the reprex package (v0.2.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment