1. 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 analysts are often able to use whichever tool they prefer, it is often important for groups 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 potential data scientists gain a better understanding of things that they 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('datasets/kagglesurvey.csv') %>%
  select( WorkToolsSelect, LanguageRecommendationSelect, EmployerIndustry, WorkAlgorithmsSelect)

# Printing the first 10 rows
head(responses, 10)

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$WorkToolsSelect[1]
## [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 = strsplit(tools$WorkToolsSelect, ',')) %>%
    unnest()

# Viewing the first 6 rows of tools
head(tools)

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)  %>% 
    filter(work_tools != 'NA') %>%
    summarise(count = length(work_tools))


# Sorting tool_count so that the most popular tools are at the top
tool_count <- arrange(tool_count, desc(count))

# Printing the first 6 results
head(tool_count)

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', debate_tools$WorkToolsSelect) & !grepl('Python', debate_tools$WorkToolsSelect) ~ 'R',
       !grepl('R', debate_tools$WorkToolsSelect) & grepl('Python', debate_tools$WorkToolsSelect) ~ 'Python',
       grepl('R', debate_tools$WorkToolsSelect) & grepl('Python', debate_tools$WorkToolsSelect) ~ 'Both',
       !grepl('R', debate_tools$WorkToolsSelect) & !grepl('Python', debate_tools$WorkToolsSelect) ~ 'Neither'
   ))

table(debate_tools$language_preference)
## 
##    Both Neither  Python       R 
##    3660    2860    2413    1220
# Printing the first 6 rows
head(debate_tools)

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(count = length(language_preference))  %>% 

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

# Creating a bar chart
ggplot(debate_plot, aes(x = reorder(language_preference, desc(count)), y = count, fill = language_preference)) +
    geom_bar(stat = 'identity') +
    labs(x = 'Preferred Language' , y = 'Count', fill = '') +
    theme_classic() +
    theme(legend.position = 'none') 

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(count = length(LanguageRecommendationSelect)) %>%
      # Removing empty responses and include the top recommendations
    filter(!LanguageRecommendationSelect == 'NA') %>%
    arrange(language_preference,desc(count)) %>%
    mutate(row_number()) %>%
    filter(row_number() <= 4)

recommendations

9. The moral of the story

So 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, R users are highly likely to recommend that new learners learn R. Python, however, seems to win out on name recognition as those respondents who do no use either R or Python are more likely to recommend Python to rising data scientists.