본문 바로가기
반응형

분류 전체보기123

(R)Cleveland dot graph - three variables (by coloring by elements of a variable) > USJR rownames(USJR) colnames(USJR)[1] mean(USJR$INTG) ------------INTG : Judical Integrity of lawyers.[1] 8.02093 > USJR%mutate(rank_INTG=ifelse(INTG table(USJR$rank_INTG)HIGH LOW 19 24 > View(USJR) > USJR_%select(NAME,CONT,rank_INTG)> View(USJR_) > USJR_ ggplot(data=USJR_,aes(x=CONT,y=NAME))+geom_point()+theme_bw()+theme(panel.grid.major.y=element_blank()) > ggplot(data=USJR_,aes(x=CONT,y=NAM.. 2020. 8. 19.
(R)divide a bar graph in to two parts by a variable / facet_wrap(vars()) > ggplot(data=UCBA,aes(x=Freq,y=Dept,fill=Gender))+geom_bar(stat="identity",position="dodge") > ggplot(data=UCBA,aes(x=Freq,y=Dept,fill=Gender))+geom_bar(stat="identity",position="dodge")+facet_wrap(vars(Gender)) > table(mpg$class) 2seater compact midsize minivan pickup subcompact 5 47 41 11 33 35 suv 62 > mpg_%filter(class=="compact"|class=="suv")%>%group_by(manufacturer)%>%mutate(mean_cty=mean.. 2020. 8. 19.
(R) Cleveland dot plot / theme_bw()/adjust elements of x-axis location/hjust/theme() >USJRrownames(USJR)colnames(USJR)[1]USJR_SUBSETnames(USJR_SUBSET) USJR_SUBSET_ ggplot(USJR_SUBSET_,aes(x=CONTACTS,y=NAMES))+geom_point() > ggplot(USJR_SUBSET_,aes(x=CONTACTS,y=reorder(NAMES,CONTACTS)))+geom_point() > ggplot(data=USJR_SUBSET_,aes(x=CONTACTS,y=reorder(NAMES,CONTACTS)))+geom_point(size=3) ggplot(data=USJR_SUBSET_,aes(x=CONTACTS,y=reorder(NAMES,CONTACTS)))+geom_point(size=3)+theme_b.. 2020. 8. 19.
(R) The way to name the unnamed first column, change the name of variables. > View(USJudgeRatings) > USJR View(USJR) > rownames(USJR) View(USJR) > colnames(USJR)[1] View(USJR) > names(USJR) [1] "NAME" "INTG" "DMNR" "DILG" "CFMG" "DECI" "PREP" "FAMI" "ORAL"[10] "WRIT" "PHYS" "RTEN" NA > USJR_SUBSET names(USJR_SUBSET)[1] "NAME" "CONT" "INTG" > names(USJR_SUBSET) names(USJR_SUBSET)[1] "NAMES" "CONTACTS" "INTEGRITY" > View(USJR_SUBSET) >library(dplyr) > USJR_SUBSET2 View(US.. 2020. 8. 19.
반응형