Learning how to Import Data

Load Packages

install.packages("haven")
Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
(as 'lib' is unspecified)
library(haven)
install.packages("tidyverse")
Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
(as 'lib' is unspecified)
library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0      ✔ purrr   1.0.1 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.3.0      ✔ stringr 1.5.0 
✔ readr   2.1.3      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
install.packages("openxlsx")
Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
(as 'lib' is unspecified)
library(openxlsx)

Import Data

Excel

dataset.xls <- read.xlsx ("Harry Potter Data.xlsx")

CSV

dataset.csv <- read_csv ("Harry Potter Data.csv")
Rows: 124 Columns: 90
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (90): StartDate, EndDate, Status, IPAddress, Progress, Duration (in seco...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

SPSS

dataset.spss <- read_sav ("Harry Potter Data.sav")

SPSS from the Web

dataset.spss.web <- read_sav ("https://osf.io/kd4ej/download")