
library(dplyr)
library(readr)

## Load the file
pvs <- read_csv("../input/page_views_sample.csv")

## Trafic volume by platforms (encoded: desktop = 1, mobile = 2, tablet =3)
pvs.traffic <- group_by(pvs, platform) %>% summarise(volume = n()) %>% arrange(desc(volume))

## Print results with platform name
pid2name <- c("desktop", "mobile", "tablet")
names(pid2name) <- 1:3
pvs.traffic <- transform(pvs.traffic, name = pid2name[platform])
pvs.traffic <- with(pvs.traffic, data.frame(platform, name, volume))
pvs.traffic