library(openxlsx)
library(tibble)
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(readr)
#Importing excel file
excel <- read.xlsx("class3practice.xlsx")
#Tibbling the excel file
tibbleexcel <- tbl_df(excel)
tibbleexcel
## # A tibble: 15 x 7
## Names num1 num2 num3 num4 num5 num6
## * <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Cinderella 4 2 3 4 5 3
## 2 Alladin 3 4 4 6 9 4
## 3 Pinocio 5 6 5 8 7 5
## 4 Dorey 6 8 2 9 6 6
## 5 Nemo 4 9 3 4 4 7
## 6 Jasmine 8 7 4 2 3 5
## 7 Jafar 3 6 5 1 6 3
## 8 Pocahontas 2 4 4 6 5 4
## 9 Gus 5 3 3 7 1 5
## 10 Lucifer 8 1 4 8 2 2
## 11 Belle 9 2 5 3 3 3
## 12 Beast 3 4 6 4 9 4
## 13 Gepetto 1 6 7 8 8 5
## 14 Aboo 4 7 8 7 6 1
## 15 Genie 6 8 7 4 5 4
#Importing CSV file
csv<-read.csv("class3practice.csv")
#Tibbling CSV file
tibblecsv <- tbl_df(csv)
tibblecsv
## # A tibble: 15 x 7
## Names num1 num2 num3 num4 num5 num6
## <fctr> <int> <int> <int> <int> <int> <int>
## 1 Cinderella 4 2 3 4 5 3
## 2 Alladin 3 4 4 6 9 4
## 3 Pinocio 5 6 5 8 7 5
## 4 Dorey 6 8 2 9 6 6
## 5 Nemo 4 9 3 4 4 7
## 6 Jasmine 8 7 4 2 3 5
## 7 Jafar 3 6 5 1 6 3
## 8 Pocahontas 2 4 4 6 5 4
## 9 Gus 5 3 3 7 1 5
## 10 Lucifer 8 1 4 8 2 2
## 11 Belle 9 2 5 3 3 3
## 12 Beast 3 4 6 4 9 4
## 13 Gepetto 1 6 7 8 8 5
## 14 Aboo 4 7 8 7 6 1
## 15 Genie 6 8 7 4 5 4
#Importing text file
txt<-read.table("class3practice.txt")
#Tibbling text file
tibbletxt <- tbl_df(txt)
tibbletxt
## # A tibble: 16 x 7
## V1 V2 V3 V4 V5 V6 V7
## <fctr> <fctr> <fctr> <fctr> <fctr> <fctr> <fctr>
## 1 Names num1 num2 num3 num4 num5 num6
## 2 Cinderella 4 2 3 4 5 3
## 3 Alladin 3 4 4 6 9 4
## 4 Pinocio 5 6 5 8 7 5
## 5 Dorey 6 8 2 9 6 6
## 6 Nemo 4 9 3 4 4 7
## 7 Jasmine 8 7 4 2 3 5
## 8 Jafar 3 6 5 1 6 3
## 9 Pocahontas 2 4 4 6 5 4
## 10 Gus 5 3 3 7 1 5
## 11 Lucifer 8 1 4 8 2 2
## 12 Belle 9 2 5 3 3 3
## 13 Beast 3 4 6 4 9 4
## 14 Gepetto 1 6 7 8 8 5
## 15 Aboo 4 7 8 7 6 1
## 16 Genie 6 8 7 4 5 4
# Importing CSV file from the web
web <- read.csv("http://www.personal.psu.edu/dlp/alphaheight_weight_dataset.csv")
#Tibbling CSV file from web
tibbleweb <- tbl_df(web)
tibbleweb
## # 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
#Importing another CSV file from the web
web2 <- read.csv("http://www.personal.psu.edu/dlp/w540/datasets/titanicsurvival.csv")
#Tibbling CSV file from web
tibbleweb2 <- tbl_df(web2)
tibbleweb2
## # 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
library(haven)
#Importing SPSS file
web3 <- read_spss("http://cehd.gmu.edu/assets/dimitrovbook/EXAMPLE_23_1.sav")
#Tibbling file
tibbleweb3 <- tbl_df(web3)
tibbleweb3
## # 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)
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.