본문 바로가기

분류 전체보기

(12)
[R] ggplot density chart Code Ref. https://www.r-graph-gallery.com/21-distribution-plot-using-ggplot2.html Basic density chart with ggplot2 Learn how to build a basic density chart with ggplot2. Reproducible R code is provided. www.r-graph-gallery.com data source https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/1_OneNum.csv # Libraries library(ggplot2) library(dplyr) library(hrbrthemes) # Load..
[R] correlation # correlation table cor(df) # 숫자형 열만 선택하여 correlation # dplyr::select_if cor(select_if(cor, is.numeric()) # na 있는 행 제외하고 숫자형 열만 선택하여 correlation cor(select_if(df[complete.cases(df),], is.numeric))
[DACON] 영화 관객수 예측 모델 개발 (R, lightGBM) https://dacon.io/competitions/open/235536/overview/description [문화] 영화 관객수 예측 모델 개발 - DACON 데이터 사이언스, 머신러닝을 처음 접하시거나,연습용으로 데이콘 대회를 경험해보고 싶으신 분들은 영화 관객수 예측을 시작하세요! 데이터를 다운받으신후 튜토리얼 코드(코드공유)와 동영 dacon.io EDA 생략된 처리 코드만 (test score: 500269.8041044748) rm(list = ls()) library(lightgbm) library(tidyverse) library(data.table) library(fastDummies) library(MLmetrics) library(lubridate) train
[R] ggplot color palette # ggplot color palette 사용 # scale_colour_brewer(palette='palette_name') mpg %>% ggplot(aes(x = cty, y = hwy)) + geom_point(aes(color = factor(class))) + scale_colour_brewer(palette="Paired") # palette 역순으로 사용 시 # scale_colour_brewer(palette="palette_name", direction = -1) mpg %>% ggplot(aes(x = cty, y = hwy)) + geom_point(aes(color = factor(class))) + scale_colour_brewer(palette="Paired", direct..
[R package] lubridate # df의 time이 date 형식일 때, year, month 추출 # year year(df$time) # month month(df$time)
[R] category 형 변수 Label encoding # data 내 category 형 변수를 factor 사용하여 숫자로 label encoding ex.) train 내 col_A라는 변수가 category형일 때 숫자로 label encoding 한 후 저장 train$col_A
[R] data.frame을 클립보드 복사 # data.frame이나 table을 클립보드로 복사 ex) df라는 data.frame을 클립보드로 복사할 때(index없이) write.table(df, "clipboard", sep = "\t", row.names = FALSE)
[R] 결측치 처리 # 결측치를 특정 값으로 대체 ex) df내 col_A 열의 결측치를 모두 0으로 대체 하여 저장 * replace_na() 사용 df % replace_na(list(col_A = 0)) * 행 조회하여 변경 df[is.na(col_A),'col_A']