Skip to content

Instantly share code, notes, and snippets.

@efi
Last active December 5, 2024 19:41
Show Gist options
  • Save efi/58c08f9a512eee98f28f1495d6848faa to your computer and use it in GitHub Desktop.
Save efi/58c08f9a512eee98f28f1495d6848faa to your computer and use it in GitHub Desktop.
rm(list=ls())
options(digits=22)
g <- expand.grid(replicate(10, 0:1, simplify=F))
m <- rowMeans(g)
unique(m)
df = data.frame()
for (j in 1:1024) {
for (i in 1:10) {
df = rbind(df,c(g[j,i],j))
}
}
colnames(df) <- c("value","sample")
df
library(dplyr)
averages <- df %>% group_by(sample) %>% summarise(average_value = mean(value))
unique(averages$average_value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment