<jupyter_start><jupyter_text>*Analytical Information Systems* Descriptive Analytics in R - Baseball SalariesProf. <NAME> für Wirtschaftsinformatik und InformationsmanagementSS 2019 Agenda1&nbsp;&nbsp;Download and preprocess data2&nbsp;&nbsp;Descriptive Statistics2.1&nbsp;&nbsp;Central Tendency2.2&nbsp;&nbsp;Variability2.3&nbsp;&nbsp;Shape3&nbsp;&nbsp;Visualization3.1&nbsp;&nbsp;Histogram3.2&nbsp;&nbsp;Faceting3.3&nbsp;&nbsp;Dot Plot Histogram3.4&nbsp;&nbsp;Boxplot  Download and preprocess data<jupyter_code>library(tidyverse)
file_url <- "https://www.dropbox.com/s/ysd0zljicq5yqfo/baseball.csv?dl=1"

file_url %>%
    read_csv2() %>%
    mutate(Salary = str_replace_all(Salary,"\\$","")) %>%
    mutate(Salary = str_replace_all(Salary,",","")) %>%
    mutate(Salary = as.numeric(Salary) / 1000000) -> salaries<jupyter_output><empty_output><jupyter_text>Have a quick look at the data<jupyter_code>glimpse(salaries)<jupyter_output><empty_output><jupyter_text>Descriptive Statistics  Central Tendency<jupyter_code>salaries %>%
  summarise(mean=mean(Salary),
            median=median(Salary))<jupyter_output><empty_output><jupyter_text>no direct function for mode<jupyter_code>salaries %>%
  group_by(Salary) %>%
  summarize(count = n()) %>%
  arrange(-count) %>%
  head(5)<jupyter_output><empty_output><jupyter_text>Variability<jupyter_code>salaries %>%
  summarise(range=max(Salary)-min(Salary),
            var=var(Salary),
            CoV=sd(Salary)/mean(Salary))<jupyter_output><empty_output><jupyter_text>Tukey's five number summary (minimum, lower-hinge, median, upper-hinge, maximum)<jupyter_code>fivenum(salaries$Salary)<jupyter_output><empty_output><jupyter_text>Summary function<jupyter_code>summary(salaries$Salary)<jupyter_output><empty_output><jupyter_text>not meaningful without comparisons - let's do on team level- range<jupyter_code>salaries %>%
  group_by(Team) %>%
  summarize(range = diff(range(Salary))) %>%
  arrange(range)<jupyter_output><empty_output><jupyter_text>- covariance<jupyter_code>salaries %>%
  group_by(Team) %>%
  summarize(cov = sd(Salary)/mean(Salary)) %>%
  arrange(cov)<jupyter_output><empty_output><jupyter_text>Shape<jupyter_code>salaries %>%
  summarise(skew=psych::skew(Salary),
            kurt=psych::kurtosi(Salary))
salaries %>%
  group_by(Team) %>%
  summarize(skew = psych::skew(Salary)) %>%
  arrange(-skew)
salaries %>%
  group_by(Team) %>%
  summarize(skew = psych::skew(Salary)) %>%
  arrange(skew)
salaries %>%
  group_by(Team) %>%
  summarize(kurt = psych::kurtosi(Salary)) %>%
  arrange(-kurt)
salaries %>%
  group_by(Team) %>%
  summarize(kurt = psych::kurtosi(Salary)) %>%
  arrange(kurt)<jupyter_output><empty_output><jupyter_text>Visualization  Histogram<jupyter_code>options(repr.plot.width=4, repr.plot.height=4) 
salaries %>%
  ggplot(aes(x=Salary)) +
  geom_histogram(fill="white", color="black")<jupyter_output><empty_output><jupyter_text>__Log scaled histogram__<jupyter_code>salaries %>%
  ggplot(aes(x=Salary)) +
  geom_histogram(fill="white", color="black") +
  scale_x_log10()<jupyter_output><empty_output><jupyter_text>Faceting__Small multiples Team with log scale__<jupyter_code>salaries %>%
  ggplot(aes(x=Salary)) +
  geom_histogram(fill="white", color="black") +
  facet_wrap(~Team) +
  scale_x_log10()<jupyter_output><empty_output><jupyter_text>__Small multiples Position with log scale__<jupyter_code>salaries %>%
  ggplot(aes(x=Salary)) + 
  geom_histogram(fill="white", color="black") + 
  facet_wrap(~Position) + 
  scale_x_log10()<jupyter_output><empty_output><jupyter_text>Dot Plot Histogram<jupyter_code>salaries %>%
  ggplot(aes(x=Salary)) + 
  geom_dotplot(binwidth = 0.5)<jupyter_output><empty_output><jupyter_text>Boxplot<jupyter_code>salaries %>%
  ggplot(aes(x=Position,y=Salary)) + 
  xlab("") + 
  geom_boxplot() + 
    coord_flip()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15526179367547951, 'fraction_numerical': 0.011145671332296526, 'mean_word_length': 8.166270783847981, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 102, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '544084', 'license': 'Apache-2.0', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1464, 'n_words': 152, 'path': 'notebooks/AIS_03_DescriptiveStatistics_SS19_vis.ipynb', 'repo_name': 'matjesg/AIS_2019', 'size': '3879'}