Communication and Social Networks (Fall 2023)/R Lab 1: Difference between revisions

From CommunityData
(Copying content from previous class)
 
No edit summary
Line 2: Line 2:


# Get your R environment is set up correctly
# Get your R environment is set up correctly
# Introduce you to the idea of R Markdown files
# Introduce you to the idea of Quarto files
# Create your first network graph
# Create your first network graph


You should have already logged into the Scholar instance of RStudio. In practical terms, that means there should be an RStudio icon somewhere on you computer. If you open RStudio at https://rstudio.scholar.rcac.purdue.edu:8787/auth-sign-in, it should look something like this:
You can either do your homework on your own computer, or you can use the lab computers. In general, you should be able to get most of the labs done on Thursdays, but you will need to do work outside of class for some labs, and for the final project.


[[File:Rstudio.png|thumb|upright=2.6|center|RStudio image from [https://en.wikipedia.org/wiki/RStudio Wikipedia]]]
This semester, we are going to try using VSCode. This is a popular, open source Interactive Development Environment. One of the cool features is that it has an AI plugin which will automatically suggest code for you. I'm hopeful that this will let you do more, faster.


If something isn't working, then revisit the [[../Scholar Setup|Scholar Setup tutorial]] and if you still can't get it then reach out on Discord and we'll get it figured out.


=== Install Quarto ===


* [https://rmarkdown.rstudio.com/lesson-1.html Install R Markdown]
* [https://quarto.org/docs/get-started/ Install Quarto]


* Open the <code>lab_1_r_markdown.Rmd</code> file that you loaded in the [[../Scholar Setup|Scholar Setup tutorial]]
=== Install VSCode ===
** Read through the file and try "knitting" it to an output document
 
** Finish the exercises and "knit" the file again and see how it changes the output document
* [https://code.visualstudio.com/Download Install VSCode]
** Knit the file into a PDF or Word document and upload it to Brightspace
 
=== Install R ===
 
* If you are using a personal computer, [https://cran.r-project.org/ Install R]. This is a really old, janky-looking site, but I promise it's real.
 
=== Try to run the lab ===
 
# Create a folder on your computer called COM_411_Labs
# Download [https://jeremydfoote.com/Communication-and-Social-Networks/r_lab_assignments/lab_1_r_markdown.Rmd Lab 1] into the COM_411_Labs folder
# Open VSCode
# Click on the Extensions icon on the left (it's 3 attached squares and one floating square)
# Search for "quarto" and install the quarto extension
# Search for "R" and install the R extension
# Click File > Open Folder - Navigate to the COM_411_Labs folder
# Click on the lab_1_quarto.qmd file, and it should open in the main window of VSCode
# Try clicking "Render" at the top right. It will probably not work. This is because there are a lot of R packages that you need to install.
# Click the "R Interactive" shell at the bottom right, and paste the following:
#* <code>install.packages(c("rmarkdown","tidyverse","ggraph","tidygraph"))</code>
#* If it asks if you want to install from source, you can type "no"
#* This will show a bunch of crazy messages for a while. Hopefully, you can ignore them.
# Click "Render" again, and hopefully it works this time.
# Read the document, make the changes that you are asked to, and then try clicking the down arrow by Render, and "Render as PDF". I would like you to turn in all of your assignments as PDFs.
# If that doesn't work, then you probably have to install tinytex. Click the Quarto Preview terminal (in the bottom right) and type:
<code>quarto install tinytex</code>
# Try rendering a PDF again
# Upload the PDF to Brightspace! You did it!!
 
If things aren't working then ask a neighbor for help. If they are also stuck, ask me!
 
 
=== Set up Github Copilot ===
 
If you want to use Github Copilot
# Sign up for an account at [https://education.github.com/students Github education]
# Install the GitHub Copilot extension in VSCode
# Authenticate using the popup that shows up in the bottom right
 
We will talk more about how to use Copilot in class.

Revision as of 18:46, 10 August 2023

This lab has three goals:

  1. Get your R environment is set up correctly
  2. Introduce you to the idea of Quarto files
  3. Create your first network graph

You can either do your homework on your own computer, or you can use the lab computers. In general, you should be able to get most of the labs done on Thursdays, but you will need to do work outside of class for some labs, and for the final project.

This semester, we are going to try using VSCode. This is a popular, open source Interactive Development Environment. One of the cool features is that it has an AI plugin which will automatically suggest code for you. I'm hopeful that this will let you do more, faster.


Install Quarto

Install VSCode

Install R

  • If you are using a personal computer, Install R. This is a really old, janky-looking site, but I promise it's real.

Try to run the lab

  1. Create a folder on your computer called COM_411_Labs
  2. Download Lab 1 into the COM_411_Labs folder
  3. Open VSCode
  4. Click on the Extensions icon on the left (it's 3 attached squares and one floating square)
  5. Search for "quarto" and install the quarto extension
  6. Search for "R" and install the R extension
  7. Click File > Open Folder - Navigate to the COM_411_Labs folder
  8. Click on the lab_1_quarto.qmd file, and it should open in the main window of VSCode
  9. Try clicking "Render" at the top right. It will probably not work. This is because there are a lot of R packages that you need to install.
  10. Click the "R Interactive" shell at the bottom right, and paste the following:
    • install.packages(c("rmarkdown","tidyverse","ggraph","tidygraph"))
    • If it asks if you want to install from source, you can type "no"
    • This will show a bunch of crazy messages for a while. Hopefully, you can ignore them.
  11. Click "Render" again, and hopefully it works this time.
  12. Read the document, make the changes that you are asked to, and then try clicking the down arrow by Render, and "Render as PDF". I would like you to turn in all of your assignments as PDFs.
  13. If that doesn't work, then you probably have to install tinytex. Click the Quarto Preview terminal (in the bottom right) and type:

quarto install tinytex

  1. Try rendering a PDF again
  2. Upload the PDF to Brightspace! You did it!!

If things aren't working then ask a neighbor for help. If they are also stuck, ask me!


Set up Github Copilot

If you want to use Github Copilot

  1. Sign up for an account at Github education
  2. Install the GitHub Copilot extension in VSCode
  3. Authenticate using the popup that shows up in the bottom right

We will talk more about how to use Copilot in class.