library(learnr) library(tidyverse) library(bizstatp) knitr::opts_chunk$set(echo = FALSE)
course
데이터를 이용하여 다음 문제를 풀어보시오. (참고자료: R 프로그래밍)
course
course
데이터의 mid
를 가록축으로 final
을 세로축으로 하여 산점도를 그리시오. ggplot() + geom_point(mapping = aes(x = ..., y = ...), data = ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final), data = course)
course
데이터의 hw
를 가록축으로 scroe
을 세로축으로 하여 산점도를 그리시오. ggplot() + geom_point(..., ...)
ggplot() + geom_point(mapping = aes(x = hw, y = score), data = course)
course
데이터의 mid
를 가록축으로 final
을 세로축으로 하여 산점도를 그리시오. 단, 성별(gender
)에 따라 점의 색상을 다르게 표시하시오. ggplot() + geom_point(mapping = aes(x = ..., y = ..., color = ...), data = ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final, color = gender), data = course)
course
데이터의 mid
를 가록축으로 final
을 세로축으로 하여 산점도를 그리시오. 단, 학년(year
)에 따라 점의 색상과 모양을 다르게 표시하시오. ggplot() + geom_point(..., ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final, color = year, shape = year), data = course)
course
데이터를 이용하여 다음 문제를 풀어보시오. (참고자료: R 프로그래밍)
course
데이터의 mid
를 가록축으로 final
을 세로축으로 하여 산점도를 그리시오. 단, 점의 색이 데이터 값에 상관없이 모두 orange 색이 되도록 하시오. ggplot() + geom_point(mapping = aes(x = ..., y = ...), data = ..., color = ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final), data = course, color = "orange")
course
데이터의 mid
를 가록축으로 final
을 세로축으로 하여 산점도를 그리시오. 단, 점의 색이 데이터 값에 상관없이 모두 파란색이 되도록 하시오. 그리고 점의 크기를 기본 크기보다 3배 키우시오. ggplot() + geom_point(mapping = ..., data = ..., color = ..., size = ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final), data = course, color = "blue", size = 3)
course
데이터를 이용하여 다음 문제를 풀어보시오. (참고자료: R 프로그래밍)
course
데이터의 mid
를 가록축, final
을 세로축으로 산점도를 그린다. 단, gender
를 기준으로 측면으로 나누어 별도의 그래프로 그려지도록 하시오.ggplot() + geom_point(mapping = aes(x = ..., y = ...), data = ...) + facet_wrap(~ ...)
ggplot() + geom_point(mapping=aes(x=mid, y=final), data=course) + facet_wrap(~ gender)
course
데이터의 mid
를 가록축, final
을 세로축으로 산점도를 그린다. 단, gender
와 class
를 기준으로 측면으로 나누어 별도의 그래프로 그려지도록 하시오. gender
를 행으로, class
를 열로 그래프를 배치하시오.ggplot() + geom_point(mapping = aes(x = ..., y = ...), data = ...) + facet_gid(... ~ ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final), data = course) + facet_grid(gender ~ class)
course
데이터를 이용하여 다음 문제를 풀어보시오. (참고자료: R 프로그래밍)
course
데이터에서 mid
를 가로축, final
을 세로축으로 하여 산점도와 추세선을 한 그래프에 겹쳐서 표현하시오.ggplot() + geom_point(mapping = aes(x = ..., y = ...), data = ...) + geom_smooth(mapping = aes(x = ..., y = ...), data = ...)
ggplot() + geom_point(mapping = aes(x = mid, y = final), data = course) + geom_smooth(mapping = aes(x = mid, y = final), data = course)
ggplot()
함수로 옮겨 실행해 보시오.ggplot(data = ..., mapping = ...) + geom_point() + geom_smooth()
ggplot(data = course, mapping=aes(x = mid, y = final)) + geom_point() + geom_smooth()
gender
에 따라 점과 추세선의 색이 다르게 표현해 보시오. ggplot(data = ..., mapping = aes(x = ..., y = ..., color = ...)) + geom_point() + geom_smooth()
ggplot(data = course, mapping=aes(x = mid, y = final, color = gender)) + geom_point() + geom_smooth()
ggplot()
, aes()
의 첫번째, 두번째 인수의 이름을 제외해도 잘 실행되는 것을 확인해 보시오. ggplot(..., aes(..., ..., color = ...)) + geom_point() + geom_smooth()
ggplot(course, aes(mid, final, color = gender)) + geom_point() + geom_smooth()
gender
에 따르게 다른 색상이 되게 하지만, 추세선은 모든 데이터에 대하여 공통의 추세선 하나만 그려보시오. 4번과 5번 결과를 비교하여 각 geom 함수에 매핑을 하면 해당 그래프 층에만 영향을 주는 것을 확인하시오. ggplot(..., aes(..., ...)) + geom_point(aes(color = ...)) + geom_smooth()
ggplot(course, aes(mid, final)) + geom_point(aes(color = gender)) + geom_smooth()
course
데이터에서 mid
와 final
모두 90점 이상인 학생의 데이터를 뽑아보시오.filter(course, ... >= ..., ... >= ...)
filter(course, mid >= 90, final >= 90)
mid
와 final
이 모두 90 점 이상인 학생을 표시하는 점을 모두 orange 색으로 크기 3이 되도록 표시해 보시오. ggplot(..., aes(..., ...)) + geom_point(aes(color = ...)) + geom_smooth() + geom_point(data = ..., color = ..., size = ...)
ggplot(course, aes(mid, final)) + geom_point(aes(color = gender)) + geom_smooth() + geom_point(data = filter(course, mid >= 90, final >= 90), color = "orange", size = 3)
course
데이터를 이용하여 다음 문제를 풀어보시오. (참고자료: R 프로그래밍)
course
데이터에서 year
열에 대한 절대 빈도를 막대그래프로 그려보시오. ggplot(...) + geom_bar(aes(...))
ggplot(course) + geom_bar(aes(year))
course
데이터에서 year
열에 대한 상대 빈도를 막대그래프로 그려보시오. ggplot(...) + geom_bar(aes(..., ..., group = 1))
ggplot(course) + geom_bar(aes(year, ..prop.., group = 1))
course
데이터에서 score
열에 대한 히스토그램을 그려보시오. ggplot(...) + geom_histogram(aes(...))
ggplot(course) + geom_histogram(aes(score))
course
데이터에서 score
열에 대한 히스토그램을 그려보시오. 단, 구간의 넓이가 10점이 되도록 하시오.ggplot(...) + geom_histogram(aes(...), binwidth = ...)
ggplot(course) + geom_histogram(aes(score), binwidth = 10)
course
데이터를 이용하여 다음 문제를 풀어보시오. (참고자료: R 프로그래밍)
course
데이터에서 year
열에 대한 빈도를 막대그래프로 그리는데, gender
별로 구별되는 색상으로 막대그래프가 층으로 쌓이도록 그려보시오. ggplot(...) + geom_bar(aes(..., ... = ...))
ggplot(course) + geom_bar(aes(year, fill = gender))
course
데이터에서 year
열에 대한 빈도를 막대그래프로 그리는데, gender
별로 구별되는 색상으로 막대그래프가 나란히 그려보시오. ggplot(...) + geom_bar(aes(..., ... = ...), position = ...)
ggplot(course) + geom_bar(aes(year, fill = gender), position = "dodge")
course
데이터에서 year
열에 대한 막대그래프로 그리는데, gender
별로 구별되는 색상으로 막대그래프를 그리고, year
별로는 막대 길이가 1이 되도록 하여 학년별 성별 차이를 확인할 수 있도록 그리시오. ggplot(...) + geom_bar(aes(..., ... = ...), position = ...)
ggplot(course) + geom_bar(aes(year, fill = gender), position = "fill")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.