본문 바로가기
빅데이터분석기사

빅분기 ) 빅분기 4회 실기 기출 풀어보기 작업형1유형 with R

by C.Mond 2023. 10. 7.
728x90
728x90

df.csv
0.41MB
df_2.csv
0.22MB
df_3.csv
3.43MB

library(stringr)
df <- read.csv()
#Temperature컬럼에서 숫자가 아닌 문자들을 제거후 숫자 타입으로 바꾸고 3분위수에서 1분위수의 차이를 소숫점 이하 2자리까지 구하여라
str(df)
table(df$Temperature)
df$Temperature <- as.numeric(df$Temperature)
num <- df$Temperature[!is.na(df$Temperature)]
result_1 <- round(quantile(num)[4]-quantile(num)[2],2)

print(result_1)



df_2 <- read.csv()
#Likes를 Comments로 나눈 비율이 20이상이면서 Keyword값이 minecraft인 영상들의 Views값의 평균을 정수로 구하여라
df_2$Likes_Comments_ratio <- df_2$Likes/df_2$Comments
library(dplyr)
result_2 <- df_2 %>% 
  filter(Likes_Comments_ratio>=20,Keyword=="minecraft") %>% 
  select(Views) %>% 
  unlist() %>% 
  as.numeric() %>% 
  mean()

print(result_2)




df_3 <- read.csv()
#date_added가 2018년 1월 이면서 country가 United Kingdom 단독 제작인 데이터의 갯수
names(table(df_3$date_added))
year <- str_split(df_3$date_added,",",simplify = T)[,2]
date <- str_split(df_3$date_added,",",simplify = T)[,1]
date <- str_trim(date)
month <- str_split(date," ",simplify = T)[,1]
day <- str_split(date," ",simplify = T)[,2]

year <- str_trim(year)
year
month
day

df_3$year <- year
df_3$month <- month
table(month)
df_3$day <- day
str(df_3)
result_3 <- df_3 %>% 
  filter(year=="2018",month=="January",country=="United Kingdom") %>% 
  nrow()
print(result_3)

 

 

 

> print(result_1)
  75% 
27.44 
> print(result_2)
[1] 1789084
> print(result_3)
[1] 6
728x90
728x90

댓글