R: Input and output basics with plotting!)

Title

R: Input and output basics with plotting!)

Files

Download R input-output self-quiz solutions.pdf (50 KB)

Download R_input-output.R (2 KB)

Description

A basic tutorial of input/outputting in R, which also covers the basics of R studio! Learn to restructure data and save new files and plots.

Loading...

Media is loading
 

Publication Date

Spring 2020

City

New Orleans, LA

Disciplines

Digital Humanities | Online and Distance Education | Programming Languages and Compilers

Comments

DOWNLOAD LINKS:

R: https://mirror.las.iastate.edu/CRAN/

RStudio: https://rstudio.com/products/rstudio/download/

  • Install R first, then Rstudio. Open Rstudio

=== Self-quiz (see attached files for answers) ===

1) When a line begins with one or more “#” it will appear in grey and is called a comment. What happens when we start a line with # to make it a comment?

  1. R will skip the line entirely
  2. You will give another programmer (most likely you in the future) insights into the code you were writing
  3. It may take a bit longer and seem unnecessary, but is a valuable practice
  4. All of the above

2) What does pressing the “up arrow” key do when your cursor is in the console?

  1. Goes to your last line of code
  2. Opens a new script
  3. Moves up a directory
  4. None of the above

3) What happens if you enter a command into the console and nothing comes out?

  1. Nothing happened – you need to run the command again
  2. The command was most likely interpreted correctly! Errors will be reported in red if there is an issue
  3. Rstudio probably crashed

4) What does the $ operator do in R?

  1. Converts numerical values to currency
  2. Gets more info about a function
  3. Allows you to refer to a column within a dataframe by column name
  4. Returns the price of a subscription to Rstudio (it’s $0)

5) Why do we need to include dev.off() when writing a plot to a pdf file?

  1. It tells R to close the pdf you opened and save your data
  2. You will get an error without it
  3. You only need this when saving a complex plot
  4. You don’t need it – it’s optional

6) If you get an updated happiness report for 2020, how much work will need to be done to adapt this work to the new dataframe?

  1. You will need to do the whole thing over again
  2. You will need to redo most of this work, but you can use some
  3. You will only need to update the input file and maybe the titles of your graphs

R: Input and output basics with plotting!)

Share

COinS