First, we load the data
data(CreditCard)
CreditCard <- CreditCard %>%
filter(months != 0, card=="yes") %>%
mutate(expenses = expenditure / months)
# Create the frequency table
tabela <- Freq(CreditCard$expenses, breaks=seq(0, 500, by=50), na.include = TRUE)
kable(tabela,
col.names = c("Avg expen/mth", "Frequency", "Percentage %", "Cumulative frequency", "Cumulative percentage %")) %>%
kable_styling(bootstrap_options = "striped") %>%
column_spec(c(3, 5), background = "cornsilk", color="navy")%>%
column_spec(c(2, 4), background = "navy", color="cornsilk")%>%
kable_classic(full_width = FALSE, html_font = "Verdana")
| Avg expen/mth | Frequency | Percentage % | Cumulative frequency | Cumulative percentage % |
|---|---|---|---|---|
| [0,50] | 937 | 0.9168297 | 937 | 0.9168297 |
| (50,100] | 44 | 0.0430528 | 981 | 0.9598826 |
| (100,150] | 14 | 0.0136986 | 995 | 0.9735812 |
| (150,200] | 12 | 0.0117417 | 1007 | 0.9853229 |
| (200,250] | 8 | 0.0078278 | 1015 | 0.9931507 |
| (250,300] | 1 | 0.0009785 | 1016 | 0.9941292 |
| (300,350] | 0 | 0.0000000 | 1016 | 0.9941292 |
| (350,400] | 1 | 0.0009785 | 1017 | 0.9951076 |
| (400,450] | 1 | 0.0009785 | 1018 | 0.9960861 |
| (450,500] | 4 | 0.0039139 | 1022 | 1.0000000 |
tabela <- classIntervals(CreditCard$expenses, n=7, style="fixed", fixedBreaks=seq(0,500,by=50))
jenks.tests(tabela)
## # classes Goodness of fit Tabular accuracy
## 10.0000000 0.9490873 0.6426857
First let’s load the data
download.file("https://raw.githubusercontent.com/kflisikowski/ds/master/netflix-dataset.csv?raw=true", destfile ="dane.csv",mode="wb")
mydata<-read.csv(file="dane.csv",encoding ="UTF-8",header=TRUE,sep = ",")
attach(mydata)
We will consider a movie or series to be polish if it is available in Poland and has Polish subtitles. Now some data wrangling.
movies <- mydata %>%
filter(Languages == "Polish")%>%
filter(Country.Availability == "Poland") %>%
select( Country.Availability,Languages, Title, IMDb.Score )
ggplot(mydata, aes(IMDb.Score))+
geom_histogram(binwidth=0.1, fill = "cornsilk", color="navyblue")+
facet_wrap(vars(Series.or.Movie))
Now let’s take a look at density.
ggplot(mydata, aes(IMDb.Score), y=after_stat(density), bw=0.5)+
geom_density( fill = "cornsilk", color="navyblue")+
facet_wrap(vars(Series.or.Movie))
new <- mydata %>%
select(Languages) %>%
separate_rows(Languages, sep=", ") %>%
count(Languages, sort=TRUE) %>%
top_n(10, n)
ggplot(new, aes(x=n, y=fct_reorder(Languages, n)))+
geom_col()+
ylab("Language")+
xlab("How many titles available")
#Create a chart showing actors starring in the most popular productions.
top_productions<-mydata%>%
arrange(-IMDb.Votes)%>%
slice_head(n=50)%>%
select(Title, Actors)
actors_general<-top_productions%>%
separate_rows(Actors, sep=", " )%>%
select(Actors)
top_actors<-actors_general%>%
count(Actors)%>%
arrange(-n)%>%
slice_head(n=10)
top_actors%>%
ggplot(aes(x = Actors, y = n, fill = Actors)) +
geom_col(width = 0.7, color = "black") +
ylab("Number of Appearances") +
xlab("Actors") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1)) +
facet_wrap(vars("Top 10 actors starring in the most popular productions(50)"), scales="free")+
scale_fill_brewer(palette = "Set3")
newdata <-mydata %>%
select(IMDb.Score, Metacritic.Score, Rotten.Tomatoes.Score, Hidden.Gem.Score, Series.or.Movie) %>%
pivot_longer(cols=c("IMDb.Score", "Metacritic.Score", "Rotten.Tomatoes.Score", "Hidden.Gem.Score"), names_to="Reviewer", values_to="Rating" )
newdata
## # A tibble: 37,700 × 3
## Series.or.Movie Reviewer Rating
## <chr> <chr> <dbl>
## 1 Series IMDb.Score 7.9
## 2 Series Metacritic.Score 82
## 3 Series Rotten.Tomatoes.Score 98
## 4 Series Hidden.Gem.Score 4.3
## 5 Movie IMDb.Score 5.8
## 6 Movie Metacritic.Score 69
## 7 Movie Rotten.Tomatoes.Score 79
## 8 Movie Hidden.Gem.Score 7
## 9 Movie IMDb.Score 7.4
## 10 Movie Metacritic.Score NA
## # ℹ 37,690 more rows
ggplot(newdata, aes(x=Rating))+
geom_histogram()+
facet_wrap(vars(Reviewer, Series.or.Movie), scales="free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.