title | author | date | output | ||||||
---|---|---|---|---|---|---|---|---|---|
Lab Crossover Event |
Daniel Fuller |
11/02/2020 |
|
knitr::opts_chunk$set(echo = FALSE)
- 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.
- 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
- RStudio is the primary Integrated Develop Environment (IDE) for R
- We will be using RStudio for the tutorial
- 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 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 outputread_csv
= the name of the function()
= what you input into the function
2+2
a <- 2+2
a + a
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")
nl_candidates$`Number of Votes Obtained` <- as.numeric(nl_candidates$`Number of Votes Obtained`)
summary(nl_candidates$`Number of Votes Obtained`)
library(tidyverse)
nl_candidates <- nl_candidates %>%
mutate(sex = case_when(
Sex == 1 ~ "Male",
Sex == 2 ~ "Female"))
ggplot(nl_candidates, aes(sex, `Number of Votes Obtained`, fill = sex)) +
geom_boxplot() +
theme_classic()
Two similar but different methods for many common tasks
- CRAN Task View
- META Cran
- Follow prominent voices
- http://m-clark.github.io/docs/RSocialScience.pdf
- Twitter Sentiment Analysis
- RStudio + Github
- Full Scientific Paper with R and RMarkdown