devtools::install_github("hrbrmstr/taucharts")
## Skipping install of 'taucharts' from a github remote, the SHA1 (93dbdce5) has not changed since last install.
##   Use `force = TRUE` to force installation

Importing the file to R

sheeturl="https://docs.google.com/spreadsheets/d/1Yv_9nDl4ocIZR0GXU3OZuBaXxER1blfwR_XHvklPpEM/edit?hl=en&hl=en&hl=en#gid=0"

library(googlesheets)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0     ✓ purrr   0.3.3
## ✓ tibble  3.0.0     ✓ dplyr   0.8.3
## ✓ tidyr   1.0.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
library(htmlwidgets)
library(DT)
library(taucharts)
tedtalkssheet <- sheeturl %>% gs_url()
## Sheet-identifying info appears to be a browser URL.
## googlesheets will attempt to extract sheet key from the URL.
## Putative key: 1Yv_9nDl4ocIZR0GXU3OZuBaXxER1blfwR_XHvklPpEM
## Worksheets feed constructed with public visibility
## Warning: `as_data_frame()` is deprecated as of tibble 2.0.0.
## Please use `as_tibble()` instead.
## The signature and semantics have changed, see `?as_tibble`.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
tt <- tedtalkssheet %>% gs_read()
## Accessing worksheet titled 'TEDTalks by date'.
## Parsed with column specification:
## cols(
##   `Talk ID` = col_double(),
##   public_url = col_character(),
##   speaker_name = col_character(),
##   headline = col_character(),
##   description = col_character(),
##   event = col_character(),
##   duration = col_time(format = ""),
##   language = col_character(),
##   published = col_character(),
##   tags = col_character()
## )

1.

Value of Time

hour(tt$duration[1])
## [1] 0
minute(tt$duration[1])
## [1] 16
second(tt$duration[1])
## [1] 17

Finding Duration of Talks

tt <- tt %>% mutate(duration_minutes=(second(duration)+60*minute(duration)+3600*hour(duration))/60)

Showing Total Talks and Average Duration in Minutes

tedspeakeranalysis <- tt %>% group_by(speaker_name)%>%
summarise(Number_talks=length(speaker_name),
Mean_talk_duration=mean(duration_minutes))

tedspeakeranalysis$Mean_talk_duration <- round(tedspeakeranalysis$Mean_talk_duration,2)

Displaying the Data

datatable(tedspeakeranalysis)

2.

Display speakers who have given more than three Ted Talks

tedspeakeranalysis %>% filter(Number_talks>3)%>% ggplot(.,aes(reorder(speaker_name, Mean_talk_duration),Mean_talk_duration))+geom_bar(stat="identity")+coord_flip()

tedspeakeranalysis %>% filter(Number_talks>3)%>% ggplot(.,aes(reorder(speaker_name, Mean_talk_duration),Mean_talk_duration))+geom_bar(stat="identity")+coord_flip()+labs(x="",y="Mean Talk Duration")+theme_bw()

Add color

tedspeakeranalysis %>% filter(Number_talks>3)%>% ggplot(.,aes(reorder(speaker_name, Mean_talk_duration),Mean_talk_duration, fill=as.factor(Number_talks)))+geom_bar(stat="identity")+coord_flip()+labs(x="",y="Average Talk Duration")+theme_bw()

tedspeakeranalysis %>%filter(Number_talks>3)%>%ggplot(.,aes(reorder(speaker_name, Mean_talk_duration), Mean_talk_duration, fill=Number_talks))+geom_bar(stat = "identity")+coord_flip()+labs(x="","Mean Talk Duration")+theme_bw()

Cleaning Up

tedspeakeranalysis %>% filter(Number_talks>3)%>% ggplot(.,aes(reorder(speaker_name, Mean_talk_duration),Mean_talk_duration, fill=as.factor(Number_talks)))+geom_bar(stat="identity")+coord_flip()+labs(x="",y="Average Talk Duration")+theme_bw()+scale_fill_discrete("Number of Talks")

3.

Cleaning Up Tags

tedtags <- tt %>% select(tags) %>% separate(tags,c("tag1","tag2","tag3","tag4","tag5","tag6","tag7","tag8","tag9","tag10","tag11","tag12","tag13","tag14","tag15","tag16","tag17","tag18","tag19","tag20","tag21","tag22","tag23","tag24","tag25","tag26","tag27","tag28","tag29","tag30","tag31","tag32","tag33","tag34","tag35","tag36","tag37","tag38","tag39","tag40","tag41","tag42","tag43","tag44","tag45","tag46","tag47","tag48","tag49","tag50"),sep=",") %>%
  gather(tagnum, Tag, tag1:tag50) %>%
  filter(Tag != "")
## Warning: Expected 50 pieces. Missing pieces filled with `NA` in 2748 rows [1, 2,
## 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].
head(tedtags)
## # A tibble: 6 x 2
##   tagnum Tag               
##   <chr>  <chr>             
## 1 tag1   alternative energy
## 2 tag1   simplicity        
## 3 tag1   MacArthur grant   
## 4 tag1   children          
## 5 tag1   demo              
## 6 tag1   entertainment
tedtags$Tag <- trimws(tedtags$Tag)
tedtags$Tag <- tolower(tedtags$Tag)

Display Data Graphically

totaltags <-tedtags %>% group_by(Tag)%>%summarise(Tag_count=length(Tag))%>%arrange(-Tag_count)
totaltags$Tag=fct_inorder(totaltags$Tag)
tauchart(totaltags[1:20,])%>%tau_bar("Tag_count","Tag",horizontal = "TRUE")%>% tau_legend()%>% tau_tooltip()
## Neither color nor size aesthetics have been mapped. Legend plugin will be active but not displayed.