Skip to content

Instantly share code, notes, and snippets.

@south-str
Created December 16, 2015 00:21
Show Gist options
  • Save south-str/1f93e1e64dbfb1c7004c to your computer and use it in GitHub Desktop.
Save south-str/1f93e1e64dbfb1c7004c to your computer and use it in GitHub Desktop.
r test
c <- c(0,1,2,3,4)
s <- c("A","B","A","A","B")
d <- data.frame(num = c, str = s)
for(i in d$str){
cat(paste("i = ", i, "\n", sep = ""))
}
t <- table(d$str)
for(i in t){
cat(paste(i/sum(t), "\n", sep = ""))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment