so i'm trying apply summary command bunch of vectors , have each 1 labeled zip code belongs in 1 output. 1 have 1 possible? also, feel there way combine first 2 steps i'm not sure how. help!!!! here's have far:
data.06511 <- subset(x, zipcode == 6511) data.06513 <- subset(x, zipcode == 6513) data.06515 <- subset(x, zipcode == 6515) data.06516 <- subset(x, zipcode == 6516) data.06519 <- subset(x, zipcode == 6519) lackfood.06511 <- data.06511$lackfood12months_bin lackfood.06513 <- data.06513$lackfood12months_bin lackfood.06515 <- data.06515$lackfood12months_bin lackfood.06516 <- data.06516$lackfood12months_bin lackfood.06519 <- data.06519$lackfood12months_bin lackfood.pop <- x$lackfood12months_bin
here's example code. copy , paste r session see if fits bill.
dat1 <- rnorm(100) dat2 <- rnorm(100) data <- list(dat1,dat2) #makes list lapply(data,summary) #lapply applies summary function each element in list
when started programming, found apply function difficult understand. might help: https://www.r-bloggers.com/using-apply-sapply-lapply-in-r/
to answer second question doing actions many groups: split command can helpful split different groups of data. try: split(mtcars, mtcars$carb)
i wanted try combining lapply , split: lapply(split(mtcars, mtcars$carb), summary)
also, having example data makes question easier answer. hope helps
Comments
Post a Comment