Unpack rar archives in R
Asked Answered
T

3

7

I need to unpack zip and rar archives, also that must be a multiplatform solution.

In R you can unpack zip easily by command

unzip(filename, exdir=‘’)

But I found I can’t unpack rar files that way. On OS X I can simply open archive to unpack it, if I have unarchiver configured that way:

system(paste("open", path))

I googled, that 7zip can be installed and do unpacking from console, so I’ve tried installr package for Windows

require(installr)
install.7zip()
system(paste("7z x", path))

but I get warning and nothing happens

running command '7z x 1.rar’ had status 127

and terminal command for Unix

system('sudo apt-get install p7zip-rar')
system(paste("7z x ", path))

but it returned error with sudo

sudo: no tty present and no askpass program specified
Treulich answered 4/3, 2015 at 11:45 Comment(1)
Check this #46629344Jinks
K
1

To support unpacking RAR archives on any platform by your own application I suggest to integrate UnRAR source code into your application. The source code is written in C++. So you would need to compile this source code for all platforms with a C++ compiler and add the generated application to your R application package.

Well, there is also free UnRAR for Windows (x86 and x64), Linux, Mac OS X and other operating systems for various processors on WinRAR and RAR archiver addons page. So you could create also a package with your R app and suitable UnRAR application for each platform you want to support.

Keating answered 6/4, 2015 at 20:45 Comment(0)
C
1

You can just run

sudo apt-get install p7zip-rar

in a terminal, you have an error because in rstudio, you cannot be asked for your password.

Contiguous answered 13/4, 2016 at 19:8 Comment(0)
R
0

In Windows, you can use untar to unpack a RAR file.

But in Linux, I failed. Still trying to fix it.

Ripp answered 21/6, 2020 at 3:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.