Extract bz2 file in R
You can use any of these two commands:
read.csv()
command: with this command you can directly supply your compressed filename containing csv file.read.csv("file.csv.bz2")
read.table()
command: This command is generic version ofread.csv()
command. You can set delimiters and others options thatread.csv()
automatically sets. You don't need to uncompress the file separately. This command does it automatically for you.read.csv("file.csv.bz2", header = TRUE, sep = ",", quote = "\"",...)
Like this:
readcsvbz2file <- read.csv(bzfile("file.csv.bz2"))