본문 바로가기
반응형

r16

(R)Make a new variable/ mutate() mutate() : make a new variable 'msleep' is a data set in ggplot2 which consists of 'name', 'genus' , 'vore',...'bodywt'. I will make a new data set named 'new_msleep' which contains a new variable 'ratio_ram' which does not exist in 'msleep' data set. >library(ggplot2) -----------for dataset 'msleep' in ggplot2>library(dplyr) ------------for mutate(), filter() > str(msleep)tibble [61 x 12] (S3: .. 2020. 7. 27.
(R) [dplyr] Rearrange data in order / arrange() / arrange(desc()) >library(ggplot2)>library(dplyr) > the_number_of_each_manu%group_by(manufacturer)%>%summarise(n=n()) > the_number_of_each_manu# A tibble: 15 x 2 manufacturer n 1 audi 18 2 chevrolet 19 3 dodge 37 4 ford 25 5 honda 9 6 hyundai 14 7 jeep 8 8 land rover 4 9 lincoln 310 mercury 411 nissan 1312 pontiac 513 subaru 1414 toyota 3415 volkswagen 27 arrange()-order in the smallest to the largest > the_numb.. 2020. 7. 26.
(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.
반응형