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

From CommunityData
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 25: Line 25:


# Create a folder on your computer called COM_411_Labs
# 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
# Right-click on [https://github.com/jdfoote/com_and_social_networks_labs/raw/main/lab_1_r_markdown.qmd this link to Lab 1] and save it into the COM_411_Labs folder
# Open VSCode
# Open VSCode
# Click on the Extensions icon on the left (it's 3 attached squares and one floating square)
# 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 "quarto" and install the quarto extension
# Search for "R" and install the R extension
# Search for "R" and install the R extension
# Click File > Open Folder - Navigate to the COM_411_Labs folder
# In VSCode, Click File > Open Folder - Navigate to the COM_411_Labs folder that you created earlier
# Click on the lab_1_quarto.qmd file, and it should open in the main window of VSCode
# 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 Terminal > New Terminal. This will open a window at the bottom of VSCode. In that window type <code>R</code> and push enter. This will start an "R Interactive shell"
# Click the "R Interactive" shell at the bottom right, and paste the following:
# In the R shell, paste the following:
#* <code>install.packages(c("rmarkdown","tidyverse","ggraph","tidygraph"))</code>
#* <code>install.packages(c("rmarkdown","tidyverse","ggraph","tidygraph","igraphdata"))</code>
#* It will ask you what CRAN mirror you'd like to use. You can choose something in the US.
#* If it asks if you want to install from source, you can type "no"
#* 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.
#* This will show a bunch of crazy messages for a while. You can probably ignore them.
# Click "Render" again, and hopefully it works this time.
# Click "Render" at the top right, and hopefully it works!
# 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.
# 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:
# 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>
#* <code>quarto install tinytex</code>
# Try rendering a PDF again
# Try rendering a PDF again
# Upload the PDF to Brightspace! You did it!!  
# 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!
If things aren't working then ask a neighbor for help.


=== Video Walkthrough ===
I made a video walkthrough at https://youtu.be/7QKuOHoMoZA that may be helpful if you get stuck.


=== Set up Github Copilot ===
=== Set up Github Copilot ===

Latest revision as of 21:51, 25 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[edit]

Install VSCode[edit]

Install R[edit]

  • 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[edit]

  1. Create a folder on your computer called COM_411_Labs
  2. Right-click on this link to Lab 1 and save it 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. In VSCode, Click File > Open Folder - Navigate to the COM_411_Labs folder that you created earlier
  8. Click on the lab_1_quarto.qmd file, and it should open in the main window of VSCode
  9. Click Terminal > New Terminal. This will open a window at the bottom of VSCode. In that window type R and push enter. This will start an "R Interactive shell"
  10. In the R shell, paste the following:
    • install.packages(c("rmarkdown","tidyverse","ggraph","tidygraph","igraphdata"))
    • It will ask you what CRAN mirror you'd like to use. You can choose something in the US.
    • 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. You can probably ignore them.
  11. Click "Render" at the top right, and hopefully it works!
  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
  14. Try rendering a PDF again
  15. Upload the PDF to Brightspace! You did it!!

If things aren't working then ask a neighbor for help.

Video Walkthrough[edit]

I made a video walkthrough at https://youtu.be/7QKuOHoMoZA that may be helpful if you get stuck.

Set up Github Copilot[edit]

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.