1. Welcome to the world of data science

Throughout the world of data science, there are many languages and tools that can be used to complete a given task. While you are often able to use whichever tool you prefer, it is often important for analysts to work with similar platforms so that they can share their code with one another. Learning what professionals in the data science industry use while at work can help you gain a better understanding of things that you may be asked to do in the future.

In this project, we are going to find out what tools and languages professionals use in their day-to-day work. Our data comes from the Kaggle Data Science Survey which includes responses from over 10,000 people that write code to analyze data in their daily work.

# Loading necessary packages
library(tidyverse)

# Loading the data
responses <- read_csv("C:/Users/kpsaxon/Downloads/project (6)/Exploring the Kaggle Data Science Survey/datasets/kagglesurvey.csv")

# Printing the first 10 rows
head(responses, 10)
## # A tibble: 10 x 5
##    Respondent WorkToolsSelect            LanguageRecomme~ EmployerIndustry
##         <int> <chr>                      <chr>            <chr>           
##  1          1 Amazon Web services,Oracl~ F#               Internet-based  
##  2          2 Amazon Machine Learning,A~ Python           Mix of fields   
##  3          3 C/C++,Jupyter notebooks,M~ Python           Technology      
##  4          4 Jupyter notebooks,Python,~ Python           Academic        
##  5          5 C/C++,Cloudera,Hadoop/Hiv~ R                Government      
##  6          6 SQL                        Python           Non-profit      
##  7          7 Jupyter notebooks,NoSQL,P~ Python           Internet-based  
##  8          8 Python,Spark / MLlib,Tabl~ Python           Mix of fields   
##  9          9 Jupyter notebooks,MATLAB/~ Python           Financial       
## 10         10 C/C++,IBM Cognos,MATLAB/O~ R                Technology      
## # ... with 1 more variable: WorkAlgorithmsSelect <chr>

2. Using multiple tools

Now that we’ve loaded in the survey results, we want to focus on the tools and languages that the survey respondents use at work.

# Printing the first respondents' tools and languages
responses[1, 2]
## # A tibble: 1 x 1
##   WorkToolsSelect                                                 
##   <chr>                                                           
## 1 Amazon Web services,Oracle Data Mining/ Oracle R Enterprise,Perl
# Creating a new data frame called tools
tools <- responses

# Adding a new column to tools which splits the WorkToolsSelect column at the commas and unnests the new column
tools <- tools  %>% 
    mutate(work_tools = str_split(WorkToolsSelect, ",")) %>%
    unnest(work_tools)

# Viewing the first 6 rows of tools
head(tools, 6)
## # A tibble: 6 x 6
##   Respondent WorkToolsSelect             LanguageRecomme~ EmployerIndustry
##        <int> <chr>                       <chr>            <chr>           
## 1          1 Amazon Web services,Oracle~ F#               Internet-based  
## 2          1 Amazon Web services,Oracle~ F#               Internet-based  
## 3          1 Amazon Web services,Oracle~ F#               Internet-based  
## 4          2 Amazon Machine Learning,Am~ Python           Mix of fields   
## 5          2 Amazon Machine Learning,Am~ Python           Mix of fields   
## 6          2 Amazon Machine Learning,Am~ Python           Mix of fields   
## # ... with 2 more variables: WorkAlgorithmsSelect <chr>, work_tools <chr>

3. Counting users of each tool

Now that we’ve split apart all of the tools used by each respondent, we can figure out which tools are the most popular.

# Creating a new data frame
tool_count <- tools

# Grouping the data by work_tools, calculate the number of responses in each group
tool_count <- tool_count  %>% 
    group_by(work_tools)  %>% 
    summarise(tool_distinct = n()) %>%
    arrange(desc(tool_distinct))

# Printing the first 6 results
head(tool_count, 6)
## # A tibble: 6 x 2
##   work_tools        tool_distinct
##   <chr>                     <int>
## 1 Python                     6073
## 2 R                          4708
## 3 SQL                        4261
## 4 Jupyter notebooks          3206
## 5 TensorFlow                 2256
## 6 <NA>                       2198

5. The R vs Python debate

Within the field of data science, there is a lot of debate among professionals about whether R or Python should reign supreme. You can see from our last figure that R and Python are the two most commonly used languages, but it’s possible that many respondents use both R and Python. Let’s take a look at how many people use R, Python, and both tools.

# Creating a new data frame called debate_tools
debate_tools <- responses

# Creating a new column called language preference, based on the conditions specified in the Instructions
debate_tools <- debate_tools  %>% 
   mutate(language_preference = 
    case_when(grepl("R", WorkToolsSelect) & ! grepl("Python",WorkToolsSelect) ~ "R", 
    grepl("Python", WorkToolsSelect) & ! grepl("R", WorkToolsSelect) ~ "Python",             grepl("R", WorkToolsSelect) & grepl("Python", WorkToolsSelect) ~ "both", 
    ! grepl("R", WorkToolsSelect) & ! grepl("Python", WorkToolsSelect) ~ "neither"))

# Printing the first 6 rows
head(debate_tools, 6)
## # A tibble: 6 x 6
##   Respondent WorkToolsSelect             LanguageRecomme~ EmployerIndustry
##        <int> <chr>                       <chr>            <chr>           
## 1          1 Amazon Web services,Oracle~ F#               Internet-based  
## 2          2 Amazon Machine Learning,Am~ Python           Mix of fields   
## 3          3 C/C++,Jupyter notebooks,MA~ Python           Technology      
## 4          4 Jupyter notebooks,Python,S~ Python           Academic        
## 5          5 C/C++,Cloudera,Hadoop/Hive~ R                Government      
## 6          6 SQL                         Python           Non-profit      
## # ... with 2 more variables: WorkAlgorithmsSelect <chr>,
## #   language_preference <chr>

6. Plotting R vs Python users

Now we just need to take a closer look at how many respondents use R, Python, and both!

# Creating a new data frame
debate_plot <- debate_tools

# Grouping by language preference and calculate number of responses
debate_plot <- debate_plot  %>% 
   group_by(language_preference)  %>% 
    summarise(n = n())  %>% 

# Removing the row for users of "neither"
    filter(language_preference != "neither")

# Creating a bar chart
ggplot(debate_plot, aes(x = language_preference, y = n))+
geom_bar(stat = "identity")

7. Language recommendations

It looks like the largest group of professionals program in both Python and R. But what happens when they are asked which language they recommend to new learners? Do R lovers always recommend R?

# Creating a new data frame
recommendations <- debate_tools

# Grouping by language_preference and then LanguageRecommendationSelect
recommendations <- recommendations  %>% 
    group_by(language_preference, LanguageRecommendationSelect)  %>% 
    summarise(n = n()) %>%

# Removing empty responses and include the top recommendations
filter(LanguageRecommendationSelect != 0) %>%
arrange(desc(LanguageRecommendationSelect)) %>%
mutate(count = row_number()) %>%
filter(count <= 4)

9. The moral of the story

So we’ve made it to the end. We’ve found that Python is the most popular language used among Kaggle data scientists, but R users aren’t far behind. And while Python users may highly recommend that new learners learn Python, would R users find the following statement TRUE or FALSE?

# Would R users find this statement TRUE or FALSE?
R_is_number_one = TRUE