# Must load dplyr
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(readxl)
# Import .txt file from local computer
txtfile<-read.table("Practice 3.txt")
# Create tibble
txtfile<-tbl_df(txtfile)
txtfile
## # A tibble: 16 x 7
## V1 V2 V3 V4 V5 V6
## <fctr> <fctr> <fctr> <fctr> <fctr> <fctr>
## 1 Name Hours_Week Years_of_Service Pay_Rate Age Height_Inches
## 2 John 40 20 12 23 64
## 3 Sam 38 2 13 45 65
## 4 Kelly 38 3 14 34 70
## 5 Liz 36 4 12 23 66
## 6 Karen 20 3 23 35 62
## 7 Tami 24 6 24 44 73
## 8 Jim 28 7 11 46 74
## 9 Dave 40 8 23 56 71
## 10 Bruce 32 12 45 62 72
## 11 Dan 28 14 26 28 60
## 12 Ray 28 13 28 13 61
## 13 Heather 24 10 12 22 66
## 14 Ron 12 16 13 68 67
## 15 Alice 10 27 14 69 64
## 16 Amy 8 1 15 70 70
## # ... with 1 more variables: V7 <fctr>
# Import .csv file from my computer
csvfile<-read.csv("Practice 3.csv")
# Create "tibble"
csvfile<-tbl_df(csvfile)
csvfile
## # A tibble: 15 x 7
## Name Hours_Week Years_of_Service Pay_Rate Age Height_Inches
## <fctr> <int> <int> <int> <int> <int>
## 1 John 40 20 12 23 64
## 2 Sam 38 2 13 45 65
## 3 Kelly 38 3 14 34 70
## 4 Liz 36 4 12 23 66
## 5 Karen 20 3 23 35 62
## 6 Tami 24 6 24 44 73
## 7 Jim 28 7 11 46 74
## 8 Dave 40 8 23 56 71
## 9 Bruce 32 12 45 62 72
## 10 Dan 28 14 26 28 60
## 11 Ray 28 13 28 13 61
## 12 Heather 24 10 12 22 66
## 13 Ron 12 16 13 68 67
## 14 Alice 10 27 14 69 64
## 15 Amy 8 1 15 70 70
## # ... with 1 more variables: Weight_lbs. <int>
# Import excel file from my computer
excelfile<- read_excel("Practice 3.xlsx")
# Create "tibble"
excelfile<-tbl_df(excelfile)
excelfile
## # A tibble: 15 x 7
## Name Hours_Week Years_of_Service Pay_Rate Age Height_Inches
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 John 40 20 12 23 64
## 2 Sam 38 2 13 45 65
## 3 Kelly 38 3 14 34 70
## 4 Liz 36 4 12 23 66
## 5 Karen 20 3 23 35 62
## 6 Tami 24 6 24 44 73
## 7 Jim 28 7 11 46 74
## 8 Dave 40 8 23 56 71
## 9 Bruce 32 12 45 62 72
## 10 Dan 28 14 26 28 60
## 11 Ray 28 13 28 13 61
## 12 Heather 24 10 12 22 66
## 13 Ron 12 16 13 68 67
## 14 Alice 10 27 14 69 64
## 15 Amy 8 1 15 70 70
## # ... with 1 more variables: Weight_lbs. <dbl>
# Import .csv file from the web
csvwebfile<-read.csv("http://www.personal.psu.edu/dlp/alphaheight_weight_dataset.csv")
# Create a "tibble"
csvwebfile<-tbl_df(csvwebfile)
csvwebfile
## # 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
# Import .csv from web
csvwebfile2<-read.csv("http://www.personal.psu.edu/dlp/w540/datasets/titanicsurvival.csv")
#Create "tibble"
csvwebfile2<- tbl_df(csvwebfile2)
csvwebfile2
## # 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
# Import SSPS.sav file from the web
library(haven)
spssfile<-read_sav("https://cehd.gmu.edu/assets/dimitrovbook/EXAMPLE_23_1.sav")
library(dplyr)
# Create a "tibble"
spssfile<-tbl_df(spssfile)
spssfile
## # 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>