Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cforgaci committed Mar 19, 2024
1 parent d512cbb commit e393906
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions script.qmd
Original file line number Diff line number Diff line change
@@ -37,9 +37,9 @@ In this workshop, we work in a computational notebook, an environment that combi

### Software

1. During the workshop, we work in RStudio Server, a version of RStudio that is accessible through your web browser, so no installation is required. Visit [RStudio Server](http://rstudio-server-edu.bk.tudelft.nl:8787/) and log in with the credentials provided during the workshop. To follow the steps described in this document after the workshop, you will need to install [R, RStudio Desktop](https://posit.co/download/rstudio-desktop/) and [Python](https://www.python.org/downloads/) for your operating system.
1. During the workshop, we work in RStudio Server, a version of RStudio that is accessible through your web browser, so no installation is required. Visit [RStudio Server](http://rstudio-server-edu.bk.tudelft.nl:8787/) and log in with the credentials provided in your handout. To follow the steps described in this document after the workshop, you will need to install [R, RStudio Desktop](https://posit.co/download/rstudio-desktop/) and [Python](https://www.python.org/downloads/) for your operating system.

2. After opening RStudio, create a new project from `File > New Project... > Version Control > Git` with the URL `https://github.com/cforgaci/mint2324Q3U.git` and project directory name `mint2324Q3U`. Browse to a location of your choice on your computer and click on `Create Project`. This will create a project directory populated with the data and scripts used in the workshop.
2. If you haven't created an RStudio project with the workshop material yet, create it from `File > New Project... > Version Control > Git` with the URL `https://github.com/cforgaci/mint2324Q3U.git` and project directory name `mint2324Q3U`. Browse to a location of your choice on your computer and click on `Create Project`. This will create a project directory populated with the data and scripts used in the workshop.

3. Open the file `script.qmd` from the Files tab in Rstudio. This will open the computational notebook from where this document was rendered. Activate the visual editor as shown below and continue reading there.

Binary file modified script_files/figure-html/wordcloud-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 14 additions & 8 deletions script_socialmedia.html
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ <h1 class="title">What do Facebook or X users say about farming communities?</h1
</div>
</div>
<div class="callout-body-container callout-body">
<p>After analysing the Dutch news data, if you still have interests in working social media data and to hear more about citizen voice, you can follow the documents to do the very similar things. If you are reading the source document <code>script_socialmedia.qmd</code> and want to see a rendered version of it, click on the Render button above this window.</p>
<p>In this workshop, we work in a computational notebook, an environment that combines narrative, executable code and output in one place. The document you are reading is a Quarto document that combines <a href="https://www.markdowntutorial.com/">Markdown</a>, a markup language with a simple syntax for text formatting, with code chunks written in the R programming language. If you are reading the source document <code>script_socialmedia.qmd</code> and want to see a rendered version in your browser, click on the Render button above this window.</p>
</div>
</div>
<section id="setup" class="level2">
@@ -177,13 +177,13 @@ <h3 class="anchored" data-anchor-id="software-for-data-collection">Software for
<li><p>Install the Web Data Reseach Assistant extension from <a href="https://chromewebstore.google.com/detail/web-data-research-assista/kcdbekkmigohaijilebpaeoopcgjbbdm?pli=1">here</a>.</p></li>
<li><p>In Chrome, go to Facebook or X and search for keywords you are interested in, then press <kbd>Shift</kbd>+<kbd>Ctrl</kbd>+<kbd>A</kbd> to activate the data gathering process. <img src="fig/webscraping1.png" class="img-fluid"></p></li>
<li><p>Press <kbd>Shift</kbd>+<kbd>Ctrl</kbd>+<kbd>H</kbd> to halt the data gathering process and stop the browser scrolling. You will be prompted to save a <code>WebDataRE.html</code> file. <img src="fig/webscraping2.png" class="img-fluid"></p></li>
<li><p>Open the <code>WebDataRE.html</code>, select the data in the table (including the column headers), open a new Excel file and paste the copied data into it. <img src="fig/webscraping3.png" class="img-fluid"></p></li>
</ol>
<p>5.Open the <code>WebDataRE.html</code>, select the data in the table (including the column headers), open a new Excel file and paste the copied data into it. <img src="fig/webscraping3.png" class="img-fluid"></p>
</section>
<section id="software-for-analysing-data" class="level3">
<h3 class="anchored" data-anchor-id="software-for-analysing-data">Software for analysing data</h3>
<ol type="1">
<li><p>During the workshop, we work in <a href="http://rstudio-server-edu.bk.tudelft.nl:8787/">a cloud instance of RStudio</a> accessible through your web browser, so no installation is required. After the workshop, you will need to install <a href="https://posit.co/download/rstudio-desktop/">R, RStudio Desktop</a> and <a href="https://www.python.org/downloads/">Python</a> for your operating system.</p></li>
<li><p>During the workshop, we work in RStudio Server, a version of RStudio that is accessible through your web browser, so no installation is required. Visit <a href="http://rstudio-server-edu.bk.tudelft.nl:8787/">RStudio Server</a> and log in with the credentials provided in your handout. To follow the steps described in this document after the workshop, you will need to install <a href="https://posit.co/download/rstudio-desktop/">R, RStudio Desktop</a> and <a href="https://www.python.org/downloads/">Python</a> for your operating system.</p></li>
<li><p>In RStudio, create a new project from <code>File &gt; New Project... &gt; Version Control &gt; Git</code> with the URL <code>https://github.com/cforgaci/mint2324Q3U.git</code> and project directory name <code>mint2324Q3U</code>. Browse to a location of your choice on your computer and click on <code>Create Project</code>. This will create a project directory populated with the data scripts used in the workshop.</p></li>
<li><p>Open <code>script_socialmedia.qmd</code>. This will bring you to the computational notebook from where this document was rendered. Activate the visual editor and continue reading there. <img src="fig/rstudio.png" class="img-fluid"></p></li>
<li><p>For our analysis, we will need to load a number of R packages that extend the out-of-the-box functionality of R. Run the <code>setup</code> code chunk below by pressing on the green arrow in its upper right corner.</p></li>
@@ -211,10 +211,10 @@ <h3 class="anchored" data-anchor-id="software-for-analysing-data">Software for a
</section>
<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>In this workshop, we will use word clouds to reveal top keywords in the facebook or x about farmer communities.</p>
<p>In this workshop, we will use word clouds to reveal top keywords in the Facebook or X about farmer communities.</p>
<section id="the-dataset" class="level3">
<h3 class="anchored" data-anchor-id="the-dataset">The dataset</h3>
<p>We will do this together on a given dataset: two data frames of excel files which generated by Web Data Research Assistant and translated by Google. The one is from facebook and another is from x. In this instruction, we will work with data frames of social media x. After that, you will run the analysis in this document on a dataset of your choice. Run the following code chunk with the default value.</p>
<p>We will do this together on a given dataset: two data frames of Excel files which generated by Web Data Research Assistant and translated by Google. The one is from Facebook and another is from X. In this instruction, we will work with data frames of social media X. After that, you will run the analysis in this document on a dataset of your choice. Run the following code chunk with the default value.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># What data will you work with? Use one of the following two values:</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># - "facebook_x" if you want to use the default dataset</span></span>
@@ -225,7 +225,7 @@ <h3 class="anchored" data-anchor-id="the-dataset">The dataset</h3>
</section>
<section id="text-analysis" class="level2">
<h2 class="anchored" data-anchor-id="text-analysis">Text analysis</h2>
<p>Read the Excel files of facebook or x in R. We use an Excel file with X data as an example.</p>
<p>Read the Excel files of facebook or X in R. We use an Excel file with X data as an example.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co"># read the excel data from folder, using data from x for example</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>data_root <span class="ot">&lt;-</span> <span class="fu">paste0</span>(<span class="st">"data/"</span>, data_choice, <span class="st">"/"</span>, <span class="st">"x#boeren_nederland_EN.xlsx"</span>)</span>
@@ -245,7 +245,7 @@ <h2 class="anchored" data-anchor-id="text-analysis">Text analysis</h2>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">str_detect</span>(token, <span class="st">"[0-9]"</span>)) <span class="sc">%&gt;%</span> <span class="co"># Remove numbers</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="fu">nchar</span>(token) <span class="sc">&gt;</span> <span class="dv">3</span>) <span class="co"># Remove words of max. 3 characters</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>… and have a quick look at the most frequently used words. We can already guess what this set of boeren of netherlands on social media x are about: frequently used words such as “people”, “food”, and “policy” “right” indicate different areas of concern present in social media posts. Note that we have 1609 rows, each representing one distinct word. This is the vocabulary we will provide as input to the word cloud.</p>
<p>… and have a quick look at the most frequently used words. We can see frequently used words such as “people”, “food”, and “policy” “right” indicating different areas of concern present in social media posts. Note that we have 1609 rows, each representing one distinct word. This is the vocabulary we will provide as input to the word cloud.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Count the token frequency</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>fsq_words <span class="sc">%&gt;%</span> </span>
@@ -291,7 +291,13 @@ <h2 class="anchored" data-anchor-id="text-analysis">Text analysis</h2>
<h2 class="anchored" data-anchor-id="now-its-your-turn">Now it’s your turn!</h2>
<section id="exercise-visualising-scraped-data" class="level3">
<h3 class="anchored" data-anchor-id="exercise-visualising-scraped-data">Exercise: Visualising scraped data</h3>
<p>You’ve been scraping data throughout the workshop. Now it is time to visualise it. Follow the steps from the web scraping tutorial to visualise the Facebook or X data you scraped during the workshop in a word cloud. What do you see? How would you describe the discourse of/about farming communities on social media?</p>
<p>You’ve been scraping data throughout the workshop. Now it is time to visualise it.</p>
<ol type="1">
<li><p>In the <code>Files</code> tab of RStudio, click on <code>Upload</code>. Navigate to the target directory <code>~/mint2324Q3U/data/facebook_x</code>, click on <code>Choose File</code> to select the Excel file with your scraped data and click on <code>OK</code>.</p></li>
<li><p>On line 102 of this script, replace <code>x#boeren_nederland_EN.xlsx</code> with the name of your uploaded file.</p></li>
<li><p>Follow the steps of the web scraping tutorial above to visualise your social media data in a word cloud.</p></li>
</ol>
<p>What do you see? How would you describe the discourse of/about farming communities on social media?</p>
</section>
</section>

2 changes: 1 addition & 1 deletion script_socialmedia.qmd
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ During the workshop, we work with [Web Data Research Assistant](https://southamp

### Software for analysing data

1. During the workshop, we work in [a cloud instance of RStudio](http://rstudio-server-edu.bk.tudelft.nl:8787/) accessible through your web browser, so no installation is required. After the workshop, you will need to install [R, RStudio Desktop](https://posit.co/download/rstudio-desktop/) and [Python](https://www.python.org/downloads/) for your operating system.
1. During the workshop, we work in RStudio Server, a version of RStudio that is accessible through your web browser, so no installation is required. Visit [RStudio Server](http://rstudio-server-edu.bk.tudelft.nl:8787/) and log in with the credentials provided in your handout. To follow the steps described in this document after the workshop, you will need to install [R, RStudio Desktop](https://posit.co/download/rstudio-desktop/) and [Python](https://www.python.org/downloads/) for your operating system.

2. In RStudio, create a new project from `File > New Project... > Version Control > Git` with the URL `https://github.com/cforgaci/mint2324Q3U.git` and project directory name `mint2324Q3U`. Browse to a location of your choice on your computer and click on `Create Project`. This will create a project directory populated with the data scripts used in the workshop.

Binary file modified script_socialmedia_files/figure-html/wordcloud-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e393906

Please sign in to comment.