if (!require(haven)){
install.packages("haven", dependencies = TRUE)
require(haven)
}Loading required package: haven
Haven enables R to read and write various data formats used by other statistical packages by wrapping the fantastic ReadStat C library written by Evan Miller. Haven is part of the tidyverse. Currently it supports:
SAS: read_sas() reads .sas7bdat + .sas7bcat files and read_xpt() reads SAS transport files (version 5 and version 8).
SPSS: read_sav() reads .sav files and read_por() reads the older .por files. write_sav() writes .sav files.
Stata: read_dta() reads .dta files (up to version 15). write_dta() writes .dta files (versions 8-15).
https://rdocumentation.org/packages/haven/versions/2.5.1
if (!require(haven)){
install.packages("haven", dependencies = TRUE)
require(haven)
}Loading required package: haven
The tidyverse is a set of packages that work in harmony because they share common data representations and API design. The tidyverse package is designed to make it easy to install and load core packages from the tidyverse in a single command. If you’d like to learn how to use the tidyverse effectively, the best place to start is R for data science.
https://rdocumentation.org/packages/tidyverse/versions/1.3.2
if (!require(tidyverse)){
install.packages("tidyverse", dependencies = TRUE)
require(tidyverse)
}Loading required package: 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.2.1 ✔ 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()
https://rdocumentation.org/packages/summarytools/versions/1.0.1
if (!require(summarytools)){
install.packages("summarytools", dependencies = TRUE)
require(summarytools)
}Loading required package: summarytools
Warning in fun(libname, pkgname): couldn't connect to display ":0"
system might not have X11 capabilities; in case of errors when using dfSummary(), set st_options(use.x11 = FALSE)
Attaching package: 'summarytools'
The following object is masked from 'package:tibble':
view
dataset.spss <- read_sav ("Harry Potter Data (1).sav")(dataset.spss %>%
select(CoinFlip, FFM_15, Potter24) -> newVariable)# A tibble: 122 × 3
CoinFlip FFM_15 Potter24
<dbl+lbl> <dbl+lbl> <dbl+lbl>
1 1 [Heads] 3 [Neither agree nor diasgree] 3 [Draw your wand and stand your gr…
2 2 [Tails] 3 [Neither agree nor diasgree] 2 [Draw your wand and try to discov…
3 1 [Heads] 4 [Agree a little] 1 [Proceed with caution, keeping on…
4 2 [Tails] 5 [Agree Strongly] 4 [Withdraw into the shadows to awa…
5 1 [Heads] 4 [Agree a little] 2 [Draw your wand and try to discov…
6 2 [Tails] 3 [Neither agree nor diasgree] 1 [Proceed with caution, keeping on…
7 2 [Tails] 3 [Neither agree nor diasgree] 2 [Draw your wand and try to discov…
8 1 [Heads] 3 [Neither agree nor diasgree] 3 [Draw your wand and stand your gr…
9 1 [Heads] 3 [Neither agree nor diasgree] 2 [Draw your wand and try to discov…
10 1 [Heads] 3 [Neither agree nor diasgree] 3 [Draw your wand and stand your gr…
# … with 112 more rows
print(dfSummary(newVariable, graph.magnif = .75), method = 'render')Warning in png(png_loc <- tempfile(fileext = ".png"), width = 150 *
graph.magnif, : unable to open connection to X11 display ''
Warning in png(png_loc <- tempfile(fileext = ".png"), width = 150 *
graph.magnif, : unable to open connection to X11 display ''
Warning in png(png_loc <- tempfile(fileext = ".png"), width = 150 *
graph.magnif, : unable to open connection to X11 display ''
| No | Variable | Label | Stats / Values | Freqs (% of Valid) | Graph | Valid | Missing | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | CoinFlip [haven_labelled, vctrs_vctr, double] | Flip a coin. Is it heads or tails? |
|
|
118 (96.7%) | 4 (3.3%) | |||||||||||||||||||||||||||||
| 2 | FFM_15 [haven_labelled, vctrs_vctr, double] | I see Myself as Someone Who..... - Is ingenious, a deep thinker |
|
|
98 (80.3%) | 24 (19.7%) | |||||||||||||||||||||||||||||
| 3 | Potter24 [haven_labelled, vctrs_vctr, double] | Late at night, walking alone down the street, you hear a peculiar cry that you believe to have a magical source. Do you: |
|
|
102 (83.6%) | 20 (16.4%) |
Generated by summarytools 1.0.1 (R version 4.2.2)
2023-02-15