데이터의 구조

str(travel)

'data.frame': 78 obs. of 3 variables: $ cust_id : int 1 1 1 1 1 1 1 2 2 2 ... $ destination: Factor w/ 14 levels "뉴욕","런던",..: 10 11 13 7 8 2 4 10 11 13 ... $ date : Factor w/ 19 levels "1/1/16","1/10/16",..: 6 13 14 15 16 17 18 6 13 14 ...

head(travel)

cust_id destination date 1 1 오사카 1/2/16 2 1 오키나와 2/24/16 3 1 파리 3/1/16 4 1 베이징 4/10/16 5 1 상해 5/19/16 6 1 런던 6/10/16

전체 구문 수행

travel

데이터를 원하는 만큼 수를 제한해 가져오는 방법

travel[1:20,]

통합 함수를 이용해 데이터의 중복을 제거하고 겹치지 않는 데이터만 모아서 가져옴

aggregate(. ~ destination, data=travel, sum)

destination cust_id date 1 뉴욕 12 41 2 런던 26 32 3 로마 17 28 4 몰디브 22 91 5 방콕 78 77 6 베를린 53 56 7 베이징 65 64 8 상해 110 124 9 시드니 64 55 10 오사카 99 122 11 오키나와 42 97 12 이스탄불 26 43 13 파리 6 42 14 파타야 62 90