summary - Summarize each category of rows in one column using R -
i'm wondering if possible in r: have 2 columns. column (primaryhistory2.dept) has bunch of categorical data, column b (primaryhistry2.act.enroll) has numbers , nas. 
i want summary of column b each category in column a. like, "nut" in column a, want see min, max, mean, median, nas, etc. , see every category. when use summary() command.
not sure if possible.. thank in advance!
@moody_mudskipper results i'm looking for. without column names it's hard read. 
and base r, it's not doing counts nas, see lot of nas in file. 
very possible using dplyr library:
library(dplyr) most.of.the.answer = df %>% group_by(primaryhistory2.dept) %>% summarise(min = min(primaryhistry2.act.enroll, na.rm = true), max = max(primaryhistry2.act.enroll, na.rm = true), mean = mean(primaryhistry2.act.enroll, na.rm = true), median = median(primaryhistry2.act.enroll, na.rm = true)) (assuming dataframe called df)
for counting na's, try dplyr's filter feature:
count.nas = df %>% filter(is.na(primaryhistry2.act.enroll)) %>% group_by(primaryhistory2.dept) %>% summarise(count.na = n()) i'll leave merge 2 dataframes.
Comments
Post a Comment