Packages Used
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(openxlsx)
library(tibble)
library(readr)
library(utils)
library(haven)
Excel file Imported, Tibbled, and Printed
excel <- read.xlsx ("class3practice.xlsx")
excel <- tbl_df(excel)
excel
## # A tibble: 15 x 7
## names row.1 row2 row3 row4 row5 row6
## * <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 bob 1 2 9 8 7 6
## 2 betty 1 2 9 8 7 6
## 3 ruth 1 2 9 8 7 6
## 4 jenn 1 2 9 8 7 6
## 5 steve 1 2 9 8 7 6
## 6 kyle 1 2 9 8 7 6
## 7 sue 1 2 9 8 7 6
## 8 dave 1 2 9 8 7 6
## 9 daci 1 2 9 8 7 6
## 10 mark 1 2 9 8 7 6
## 11 gina 1 2 9 8 7 6
## 12 matt 1 2 9 8 7 6
## 13 sara 1 2 9 5 5 5
## 14 shan 1 2 4 4 4 4
## 15 ed 1 2 3 3 3 3
CSV file Imported, Tibbled, and Printed
csv <- read.csv("class3practice.csv")
csv <- tbl_df(csv)
csv
## # A tibble: 15 x 7
## names row.1 row2 row3 row4 row5 row6
## <fctr> <int> <int> <int> <int> <int> <int>
## 1 bob 1 2 9 8 7 6
## 2 betty 1 2 9 8 7 6
## 3 ruth 1 2 9 8 7 6
## 4 jenn 1 2 9 8 7 6
## 5 steve 1 2 9 8 7 6
## 6 kyle 1 2 9 8 7 6
## 7 sue 1 2 9 8 7 6
## 8 dave 1 2 9 8 7 6
## 9 daci 1 2 9 8 7 6
## 10 mark 1 2 9 8 7 6
## 11 gina 1 2 9 8 7 6
## 12 matt 1 2 9 8 7 6
## 13 sara 1 2 9 5 5 5
## 14 shan 1 2 4 4 4 4
## 15 ed 1 2 3 3 3 3
TXT file Imported, Tibbled, and Printed
txt <- read.table("class3practice.txt")
txt <- tbl_df(txt)
txt
## # A tibble: 15 x 7
## V1 V2 V3 V4 V5 V6 V7
## <fctr> <int> <int> <int> <int> <int> <int>
## 1 bob 1 2 9 8 7 6
## 2 betty 1 2 9 8 7 6
## 3 ruth 1 2 9 8 7 6
## 4 jenn 1 2 9 8 7 6
## 5 steve 1 2 9 8 7 6
## 6 kyle 1 2 9 8 7 6
## 7 sue 1 2 9 8 7 6
## 8 dave 1 2 9 8 7 6
## 9 daci 1 2 9 8 7 6
## 10 mark 1 2 9 8 7 6
## 11 gina 1 2 9 8 7 6
## 12 matt 1 2 9 8 7 6
## 13 sara 1 2 9 5 5 5
## 14 shan 1 2 4 4 4 4
## 15 ed 1 2 3 3 3 3
CSV Web files Imported, Tibbled, and Printed
webcsv <- read.csv("http://www.personal.psu.edu/dlp/alphaheight_weight_dataset.csv")
webcsv <- tbl_df(webcsv)
webcsv
## # A tibble: 200 x 4
## Index Height Weight Gender
## <int> <dbl> <dbl> <fctr>
## 1 1 65.78 112.99 female
## 2 2 71.52 136.49 male
## 3 3 69.40 153.03 male
## 4 4 68.22 142.34 female
## 5 5 67.79 144.30 male
## 6 6 68.70 123.30 male
## 7 7 69.80 141.49 male
## 8 8 70.01 136.46 female
## 9 9 67.90 112.37 male
## 10 10 66.78 120.67 male
## # ... with 190 more rows
httpcsv <- read.csv("http://www.personal.psu.edu/dlp/w540/datasets/titanicsurvival.csv")
httpcsv <- tbl_df(httpcsv)
httpcsv
## # A tibble: 2,201 x 4
## Class Age Sex Survive
## <int> <int> <int> <int>
## 1 1 1 1 1
## 2 1 1 1 1
## 3 1 1 1 1
## 4 1 1 1 1
## 5 1 1 1 1
## 6 1 1 1 1
## 7 1 1 1 1
## 8 1 1 1 1
## 9 1 1 1 1
## 10 1 1 1 1
## # ... with 2,191 more rows
SPSS file Imported, Tibbled, and Printed
spsssav <- read_sav("http://cehd.gmu.edu/assets/dimitrovbook/EXAMPLE_23_1.sav")
spsssav <- tbl_df(spsssav)
spsssav
## # A tibble: 1,028 x 12
## Illness Item_1 Item_2 Item_3 Item_4 Item_5 Item_6
## <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl> <dbl+lbl> <dbl+lbl>
## 1 1 4 3 3 3 4 2
## 2 0 3 2 4 3 4 3
## 3 0 4 3 4 3 3 2
## 4 1 5 5 4 5 4 5
## 5 1 2 2 2 2 2 2
## 6 0 3 2 2 3 2 1
## 7 0 2 1 1 2 1 2
## 8 0 3 2 4 4 2 2
## 9 0 2 4 3 3 3 3
## 10 1 1 1 1 1 1 1
## # ... with 1,018 more rows, and 5 more variables: Item_7 <dbl>,
## # Item_8 <dbl+lbl>, Item_9 <dbl+lbl>, Item_10 <dbl+lbl>, Item_11 <dbl>
knitr::opts_chunk$set(echo = TRUE)