다른 영화를 위한 새 리스트 만들기
잭 니콜슨의 또 다른 최신 영화 '디파티드(The Departed)'의 리뷰를 찾았습니다!
| 점수 | 댓글 |
|---|---|
| 4.6 | I would watch it again |
| 5 | Amazing! |
| 4.8 | I liked it |
| 5 | One of the best movies |
| 4.2 | Fascinating plot |
영화 제목, 배우, 리뷰 등 영화에 관한 모든 정보를 하나의 변수로 모아두면 매우 편리합니다. 이처럼 형태가 서로 다른 데이터를 함께 다루기 위해서는 리스트 변수로 묶는 것이 자연스럽습니다.
영화 제목이 포함된 movie_title과 일부 배우 이름이 포함된 movie_actors가 작업 공간에 준비되어 있습니다.
이 연습은 강의의 일부입니다
R 입문
연습 안내
- 위 표의 리뷰 정보를 담은
scores와comments두 벡터를 만드세요. scores벡터의 평균을 구하여avg_review로 저장하세요.scores와comments벡터를 결합하여reviews_df라는 데이터 프레임을 만드세요.movie_title, 데이터 프레임movie_actors,avg_review,reviews_df를 포함하는departed_list라는 리스트를 만들고 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Use the table from the exercise to define the comments and scores vectors
scores <- c(4.6, 5, 4.8, 5, ___
comments <- c("I would watch it again", "Amazing!", "I liked it", "One of the best movies", ___
# Save the average of the scores vector as avg_review
# Combine scores and comments into the reviews_df data frame
# Create and print out a list, called departed_list