반응형 분류 전체보기123 Markov's Inequality 마르코프 부등식 Markov's Inequality Markov's Inequality is one of the most important and basic Inequalities. You can find the upper bound of probability that nonnegative random variable(X) is equal or greater than a positive constant(C). P(g(X)≥C) ≤ E(g(X))/C g(X): nonnegative function C: any positive constant 2020. 7. 23. (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. 이전 1 ··· 25 26 27 28 29 30 31 다음 반응형