What are ASCII files?


Loading data into R

file.exists("set1_set2.csv")
## [1] TRUE
sets <- read.table("set1_set2.csv", header=TRUE)    # read from disk and store in variable "sets"
class(sets)
## [1] "data.frame"
dim(sets)
## [1] 300   2
head(sets)
##        set1     set2
## 1 1.8329159 3.730824
## 2 0.5397876 5.064780
## 3 1.2170686 5.958580
## 4 1.3883328 2.029921
## 5 1.7145705 2.378172
## 6 0.8423617 1.399623
sets1 <- read.csv("set1_set2.csv", header=TRUE)     # alternative (header=TRUE is default)
class(sets1)
## [1] "data.frame"


Exporting data from R

write.table(sets, file = "my_ascii.txt")
file.exists("my_ascii.txt")
## [1] TRUE


Getting data from the web

pinched_data <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
head(pinched_data)
##   admit gre  gpa rank
## 1     0 380 3.61    3
## 2     1 660 3.67    3
## 3     1 800 4.00    1
## 4     1 640 3.19    4
## 5     0 520 2.93    4
## 6     1 760 3.00    2