Extract bz2 file in R

You can use any of these two commands:

  1. read.csv()command: with this command you can directly supply your compressed filename containing csv file.

    read.csv("file.csv.bz2")

  2. read.table() command: This command is generic version of read.csv() command. You can set delimiters and others options that read.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"))

Tags:

R

Bzip2