I wish to download and open the following tar.gz
file in R:
http://s.wordpress.org/resources/survey/wp2011-survey.tar.gz
Is there a command which can accomplish this?
Simply right-click the item you want to compress, mouseover compress, and choose tar. gz. You can also right-click a tar. gz file, mouseover extract, and select an option to unpack the archive.
Extracting files from a tar archive is done with untar function from the utils package (which is included in base R). This will extract all files in "bar. tar" to the "foo" directory, which will be created if necessary. Tilde expansion is done automatically from your working directory.
To extract (unzip) a tar.gz file simply right-click on the file you want to extract and select “Extract”. Windows users will need a tool named 7zip to extract tar.gz files. The -v option will make the tar command more visible and print the names of the files being extracted on the terminal. tar -xvf archive.tar.gz. Copy.
To extract (unzip) a tar.gz file simply right-click on the file you want to extract and select “Extract”. Windows users will need a tool named 7zip to extract tar.gz files.
You can use the official GNU gzip utility to extract the content of the compressed archive file. If the file you're looking at is a TAR.GZ, using either tar or 7-Zip to extract the file will be a much simpler choice. What Is a GZ File and How Do You Unzip It?
To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things: f: this must be the last flag of the command, and the tar f ile must be immediately after. It tells tar the name and path of the compressed file.
fn <- "http://s.wordpress.org/resources/survey/wp2011-survey.tar.gz" download.file(fn,destfile="tmp.tar.gz") untar("tmp.tar.gz",list=TRUE) ## check contents untar("tmp.tar.gz") ## or, if you just want to extract the target file: untar("tmp.tar.gz",files="wp2011-survey/anon-data.csv") X <- read.csv("wp2011-survey/anon-data.csv")
Offhand, I don't know of a way to reach into the tar file and read the appropriate csv file without unpacking it ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With