본문 바로가기
반응형

R71

(R) Fill,Color columns based on a variable/aes(x=,y=,fill=)/geom_col(position="dodge") Colored Columns The way to make filled columns which consist of three variables. [R] - (R) ifelse()diamonds {ggplot2}R Documentation FormatA data frame with 53940 rows and 10 variables: priceprice in US dollars (\$326–\$18,823)caratweight of the diamond (0.2–5.01)xlength in mm (0–10.74)ywidth in mm (0–58.9)zdepth in mm (0–31.8) You should decide three variables assigned to X-axis, Y-axis, Fill.I.. 2020. 7. 24.
(R) ifelse() ifelse() Using ifelse(), you can make a new variable based on the test you made. >library(ggplot2)> summary(diamonds$carat) -------------carat: size of carat in each diamond Min. 1st Qu. Median Mean 3rd Qu. Max. 0.2000 0.4000 0.7000 0.7979 1.0400 5.0100 To make a new variable 'carattt' which consists of small and big, I will use a test in ifelse() 1st test:diamonds$carat diamonds$carattt carattt.. 2020. 7. 23.
(R) make a summary - group_by(),summarise() >library(ggplot2) ------------------for mpg>library(dplyr) ------------------for summarise() >mpg%>%summarise(mean_cty=mean(cty)) # A tibble: 1 x 1mean_cty 1 16.9 A summary of a group(drv) by mean_cty >drv_cty%group_by(drv)%>%summarise(mean_cty=mean(cty)) > drv_cty # A tibble: 3 x 2 drv mean_cty 1 4 14.32 f 20.03 r 14.1 A summary of groups of drv, manufacturer (4,f,r - Audi,Chevrolet, ...) by me.. 2020. 7. 22.
R reorder() -reorder columns in ascending order, descending order when setting aes() Reorder Columns 1. make summary (using dplyr)2. decide x-axis, y-axis3. draw columns (using ggplot2) During step3, you should use reorder() function in x-axis 1. Make Summary > library(ggplot2)> library(dplyr)> drv_cty%group_by(drv)%>%summarise(mean_cty=mean(cty))> drv_cty # A tibble: 3 x 2drv mean_cty 1 4 14.32 f 20.03 r 14.1 2. Decide X,Y axis x-axis: drv Y-axis: mean_cty 3. Draws columns > gg.. 2020. 7. 21.
반응형