Skip to content

Ressources and tools for data analysis using R in public health, kinesiology, politicial science, ecology, and mircoplastics

Notifications You must be signed in to change notification settings

walkabillylab/lab_crossover_r

Repository files navigation

title author date output
Lab Crossover Event
Daniel Fuller
11/02/2020
slidy_presentation ioslides_presentation beamer_presentation
default
default
default
knitr::opts_chunk$set(echo = FALSE)

R: The Swiss Army Knife of Science

  • The R project for statistical computing is a free open source statistical programming language and project. Follow these steps to get started.
  • The main advantages of R are the fact that R is freeware and that there is a lot of help available online.

Why use R?

  • Strengths
    • free and open source, supported by a strong user community
    • highly extensible and flexible
    • implementation of modern statistical methods
    • assists with replication and extension of your work
  • Weaknesses
    • slow with very large data sets (>1GB)
    • non-standard programming paradigms

Why use R?

  • RStudio is the primary Integrated Develop Environment (IDE) for R
  • We will be using RStudio for the tutorial

RStudio IDE

#

Packages/Libraries

  • Packages are the main R tools
  • There are 15388 packages. It's probable that if you have thought about the analysis, there is a package that is able to do it already. There are two basic steps to using a package:

Installing the package install.packages("tidyverse")

Loading the package library(tidyverse)

Packages/Libraries

  • Packages include functions that do things.

data <- read_csv("/The/Path/To/Your/File.csv")

  • data = where you want to save the data
  • <- = tell the function where to put the output
  • read_csv = the name of the function
  • () = what you input into the function

Doing simple things in R

2+2

a <- 2+2

a + a

Reading in some data

library(readr)

# data <- read_excel("/Your/File/Path/data.xls⁩")

#nl_candidates <- read_csv("nl_candidates.csv")

nl_candidates <- read_csv("https://github.com/walkabillylab/lab_crossover_r/raw/master/nl_candidates.csv")

Some quick descriptive statistics

nl_candidates$`Number of Votes Obtained` <- as.numeric(nl_candidates$`Number of Votes Obtained`)

summary(nl_candidates$`Number of Votes Obtained`)

Recoding a variable

library(tidyverse)
nl_candidates <- nl_candidates %>%
                    mutate(sex = case_when(
                            Sex == 1 ~ "Male",
                            Sex == 2 ~ "Female"))

Recoding a variable

ggplot(nl_candidates, aes(sex, `Number of Votes Obtained`, fill = sex)) + 
        geom_boxplot() +  
        theme_classic()

The great R wars

Two similar but different methods for many common tasks

Where to find packages

Ocean Plastic Sciences

Political Sciences

Workflow Revolution

About

Ressources and tools for data analysis using R in public health, kinesiology, politicial science, ecology, and mircoplastics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages