Chapter 11 Assignments part I
Try to make a histogram or a density plot on the basis of your own data! If you have multiple groups in your data, try to compare densities! If you did not send in your own data, you can try any of the dataframes below; the “Van Rooij” data might be good for practice!
11.1 Hagoort
library(tidyverse)
# install.packages("openxlsx")
library(openxlsx)
df_Ha <- read.xlsx("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Hagoort.xlsx",
sheet = "Gait parameters ", startRow = 2)
# Note; typically I would use the readxl-package, but this package
# Does not allow you to read in online-excel files
# It is wise not to have your variables be named identically! Let's fix this
df_Ha <- as_tibble(df_Ha, .name_repair = "unique")
11.2 Hogelin
library(tidyverse)
# install.packages("openxlsx")
library(openxlsx)
df_Ho <- read.xlsx("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Hogeling.xlsx")
# Note; typically I would use the readxl-package, but this package
# Does not allow you to read in online-excel files
# It is wise not to have your variable be named identically!
df_Ho <- as_tibble(df_Ha, .name_repair = "unique")
df_Ho_red <- df_Ho %>% select(1:100) %>% slice(1:100) %>% # select 100 vars & cases
mutate_at(2:99, as.numeric) # turn to numeric variables
11.3 Maat
library(tidyverse)
# The "bed"-file; has no column names!
df_Ma1 <- read_delim("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/mobPBSC_H3K4me3_D2_peaks.bed",
delim = "\t", col_names = FALSE)
# wig is a funky format that I don't understand!
# rtracklayer seems like a package needed
11.4 Van Rooij
library(tidyverse)
# install.packages("openxlsx")
library(openxlsx)
df_Ro <- read.xlsx("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Van%20Rooij.xlsx",
startRow = 3)
# Note; typically I would use the readxl-package, but this package
# Does not allow you to read in online-excel files
11.5 Santhakumar
library(tidyverse)
# install.packages("openxlsx")
library(openxlsx)
# I've turned your xls file into xlsx
df_Sa1 <- read.xlsx("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Santhakumar1.xlsx",
sheet = "Data", startRow = 4)
# Note; typically I would use the readxl-package, but this package
# Does not allow you to read in online-excel files
df_Sa2 <- read_csv("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Santhakumar2.csv")
11.6 Seibel
library(tidyverse)
# install.packages("haven")
library(haven)
df_Se <- read_sav("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Seibel.sav")
# SPSS handles labels of categorical variables a bit differently than R.
# It’s better to convert all labelled variables into factors,
# that R can more easily deal with (you don’t have to do this though!).
# You can do this simply by:
df_Se <- as_factor(df_Se)
11.7 Zhang
library(tidyverse)
# install.packages("openxlsx")
library(openxlsx)
df_Za1 <- read.xlsx("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Zhang.xlsx")
# I had to make the below excel file compatible with R by copying data to new sheet
df_Za2 <- read.xlsx("https://stulp.gmw.rug.nl/21-03-2019/ggplotworkshop/data/Zhang2.xlsx",
sheet = "Sheet1")
# Note; typically I would use the readxl-package, but this package
# Does not allow you to read in online-excel files