Data 698 Final Project

Maryluz Cruz

2021-12-13

How Social Media Affects Ones Mental Health

For this project we are going to see how social media can affect, ones mental health. In order to do this we are going to find four different articles that discuss the affects of social media on ones mental health. The four different articles are then going to be scraped so that a sentiment analysis can be run. But before we can do anything the articles first have to be read in. Using the rvest, purr, xml2, and the tidyverse package we are going to scrape the words from the articles individually, convert each of them into tables, then merge all of the tables into one.

Data Preparation

Install the packages and read in the articles.

List of the Articles

How Does Social Media Play a Role in Depression? by Nadra Nittle of verywellmind

  • The first articles discusses on how social media can play a role in depression.

Anxiety, loneliness and Fear of Missing Out: The impact of social media on young people’s mental health

  • Discusses more about the impact that social media has on young people.

The Social Dilemma: Social Media and Your Mental Health of McLean Hospital Harvard Medical Affiliate

  • The article discusses on how one should limit social media and other points.

Scrape the Web Articles

Glimpse of the first article being scraped.

With the use of SelectorGadget in order to find the html_node, the articles get scraped from the website. Since the html_nodes are different each article will be scraped individually as all of the html_codes are different.

## Rows: 1
## Columns: 2
## $ Title <chr> "The Link Between Social Media and Depression"
## $ Text  <chr> "\n\nBy some estimates, roughly 4 billion people across the worl~

Glimpse of the second article

## Rows: 1
## Columns: 2
## $ Title <chr> "Does social media cause depression?"
## $ Text  <chr> "\n\n      \n  Sign inJoinDonateLittle Kids (5-7)Tweens (10-12)B~

Glimpse of the third article

## Rows: 1
## Columns: 2
## $ Title <chr> "Anxiety, loneliness and Fear of Missing Out: The impact of soci~
## $ Text  <chr> "\n                                      \n                     ~

Glimpse of the fourth article

## Rows: 1
## Columns: 2
## $ Title <chr> "Here’s How Social Media Affects Your Mental Health | McLean Hos~
## $ Text  <chr> "\n                        \n\n                \n\n             ~

Merge the Tables

  • Since tables can only be merged two at a time, the first two tables will be merged, then the other two tables merged. After the tables have been merged the product of the merged tables are finally merged together so that finally all four tables are merged.

Glimpse of the first two tables

## Rows: 2
## Columns: 2
## $ Title <chr> "Does social media cause depression?", "The Link Between Social ~
## $ Text  <chr> "\n\n      \n  Sign inJoinDonateLittle Kids (5-7)Tweens (10-12)B~

Glimpse of the last two tables

## Rows: 2
## Columns: 2
## $ Title <chr> "Anxiety, loneliness and Fear of Missing Out: The impact of soci~
## $ Text  <chr> "\n                                      \n                     ~

Glimpse of all tables merged together

## Rows: 4
## Columns: 2
## $ Title <chr> "Anxiety, loneliness and Fear of Missing Out: The impact of soci~
## $ Text  <chr> "\n                                      \n                     ~

CSV table is Created Load CSV

## 'data.frame':    4 obs. of  3 variables:
##  $ X    : int  1 2 3 4
##  $ Title: chr  "Anxiety, loneliness and Fear of Missing Out: The impact of social media on young people’s mental health | Centr"| __truncated__ "Does social media cause depression?" "Here’s How Social Media Affects Your Mental Health | McLean Hospital" "The Link Between Social Media and Depression"
##  $ Text : chr  "\n                                      \n                        \n  \n    \n      \n      \n  Anxiety, loneli"| __truncated__ "\n\n      \n  Sign inJoinDonateLittle Kids (5-7)Tweens (10-12)By Caroline Miller, editorial director of the Chi"| __truncated__ "\n                        \n\n                \n\n                    \n                                       "| __truncated__ "\n\nBy some estimates, roughly 4 billion people across the world use networking websites such as Facebook, Twit"| __truncated__

Clean the Data and Prep for Text Analyzation

## Rows: 2,716
## Columns: 3
## $ X     <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~
## $ Title <chr> "Anxiety, loneliness and Fear of Missing Out: The impact of soci~
## $ word  <chr> "anxiety", "loneliness", "fear", "missing", "impact", "people’s"~

Table of the Word Most Used

word n
time 50
depression 42
people 33
health 30
mental 28
users 23
anxiety 22
feel 21
sleep 18
study 18

Visualization of most used words

Sentiment Analysis: NRC

  • The NRC Emotion Lexicon consist of a list of English words along with their associations together with eight basic emotions which are anger, fear, anticipation, trust, surprise, sadness, joy, and disgust and including two sentiments (negative and positive). These observations were manually prepared by crowd sourcing.

Positive NRC

word n
feeling 5
reward 5
intense 3
trip 3
hope 2
rapid 2
teach 2
alarm 1
break 1
celebrity 1
  • The top three words are feeling, reward and intense.

Negative NRC

word n
anxiety 22
fear 11
missing 11
loneliness 8
bad 6
change 6
loss 6
feeling 5
isolated 5
confidence 4
  • The top three words are anxiety, fear and missing.

Sentiment Analysis: BING

  • The bing lexicon classifies the binarily into categories of positive and negative and it is from Bing Liu and collaborators.

Table of Bing

word sentiment n
depression negative 42
anxiety negative 22
fear negative 11
symptoms negative 10
loneliness negative 8
gratification positive 7
likes positive 7
bad negative 6
loss negative 6
healthy positive 5
  • You could see that the top three words are depression, anxiety, fear, and all have a negative sentiment.

Visual of BING

Bing Visuals of All Articles

  • Here you can see which articles have the most negative or positive sentiments

Sentiment Analysis: AFINN

  • The AFINN lexicon consist of English terms that are rated manually for valency with numbers between -5(negative) and + 5(positive) by Finn Årup Nielsen between 2009 and 2011.

Visual of AFINN

  • AFINN is different on how it is grouped by since it uses the X column in order to group the sentiments.

Visual of All of the Lexicons

  • Out of all of the sentiment lexicons NRC has the most positive sentiments, and you can see that easily when all the lexicons are compared together.

Wordclouds

  • Wordclouds are an interesting way to visually see the words, the words that are bigger are the ones that are mentioned the most.

Wordcloud of all of at 30 words

Wordcloud of Bing Sentiment

Positive

## Joining, by = "word"

Negative

Evaluation of the Kaggle Dataset of Sucide notes left on social media

Clean the Data and Prep for Text Analyzation

  • Since this text was taken from different social media outlets that don’t censor what is posted some profanities had to be removed so that it doesn’t come up while analyzing the text.
## Rows: 19,979
## Columns: 2
## $ id   <int> 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,~
## $ word <chr> "writing", "stick", "feels", "honestly", "peace", "kill", "day", ~

The top most Words

word n
life 346
feel 321
time 226
people 198
anymore 164
day 147
die 133
friends 123
live 123
kill 122
  • Top three are life, feel, and time.

Visual of the most used words

Sentiment Analysis: NRC

Positive NRC

word n
feeling 67
leave 54
finally 52
hope 45
guess 41
death 37
money 28
deal 20
chance 17
break 16
  • Although these are meant to be positive sentiments the word are not exactly positive like the word dead. The top three words are feeling, leave, finally.

Negative NRC

word n
die 133
kill 122
suicide 119
pain 91
bad 86
hate 79
worse 78
feeling 67
depressed 59
hurt 53
  • The top three word are die, kill and suicide.

Sentiment Analysis: BING

word sentiment n
die negative 133
kill negative 122
suicide negative 119
love positive 96
pain negative 91
happy positive 89
bad negative 86
tired negative 83
hate negative 79
worse negative 78
  • The top three words are die, kill and suicide, and all have a negative sentiment.

Visual of BING

AFINN

Visuall of AFINN

Visual of all three Lexicons

WORDCLOUD of Kaggle Dataset

Wordcloud with BING Seniment

Positive

Negative

References

Appendix