R for absolute beginners: Instructor Notes

Dataset

De oprindelige data kan findes her: https://figshare.com/articles/SAFI_Survey_Results/6262019.

Vi bruger en meget neddroslet udgave af data, der kan downloades her: https://raw.githubusercontent.com/KUBDatalab/beginning-R/main/data/SAFI_clean.csv.

Vær sikker på at de studerende faktisk får downloaded data til rette mappe under introduktionen til R og RStudio. Vær særligt opmærksom på at visse styresystemer er case-sensitive, og læg vægt på at de skal downloade til “data”-mappen og ikke “Data”.

Har de ikke oprettet en data mappe vil download.file() give en fejl. Det er særligt vigtigt at de har styr på det!

RStudio og flere R installationer

Nogle studerende kan have flere R instalationer. På Macs vil en ny installation føre til at styresystemet skaber et symbolsk link der peger på den nye installation som ‘Current’. Undertiden går det galt, og selvom den nye R-installation kan tilgås, kan RStudio ikke finde den. Det kan føre til at den studerende kører på en ældre R-installation, og få installation af pakker til at fejl. Det kan løses på terminalen.

Start med at tjekke at den rette R-installation:

ls -l /Library/Frameworks/R.framework/Versions/

Pt bruger vi R >=4.2. Hvis den ikke er der, skal den installeres. Hvis den er - skal det symbolske link sættes til Current sættes til at pege på R >=4.2 kataloget:

ln -s /Library/Frameworks/R.framework/Versions/4.x.y /Library/Frameworks/R.framework/Version/Current

Genstart herefter RStudio.

Narrative

Before we start

Introduction to R

Starting with data

The two main goals for this lessons are:

Manipulating data with dplyr

Error: Can’t rename columns that don’t exist.
x Column NA doesn’t exist.

Make sure you have read in the CSV file with the option that interprets the "NULL" string as NA, like so:

interviews <- read_csv("data/SAFI_clean.csv", na = "NULL")

Visualizing data with ggplot2

Technical Tips and Tricks

Show how to use the ‘zoom’ button to blow up graphs without constantly resizing windows.

Sometimes a package will not install. You can try a different CRAN mirror:

Alternatively you can go to CRAN and download the package and install from ZIP file:

It is important that R, and the R packages be installed locally, not on a network drive. If a learner is using a machine with multiple users where their account is not based locally this can create a variety of issues (this often happens on university computers). Hopefully the learner will realize these issues beforehand, but depending on the machine and how the IT folks that service the computer have things set up, it may be very difficult to impossible to make R work without their help.

If learners are having issues with one package, they may have issues with another. It’s often easier to make sure they have all the needed packages installed at one time, rather than deal with these issues over and over. Here is a list of all necessary packages for these lessons.

| character on Spanish keyboards: The Spanish Mac keyboard does not have a | key. This character can be created using:

`alt` + `1`

Other Resources

If you encounter a problem during a workshop, feel free to contact the maintainers by email or open an issue.

For a more in-depth coverage of topics of the workshops, you may want to read “R for Data Science” by Hadley Wickham and Garrett Grolemund.