Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unpack rar archives in R

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
like image 285
randomsuffer Avatar asked Oct 31 '22 08:10

randomsuffer


1 Answers

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.

like image 195
Mofi Avatar answered Nov 10 '22 07:11

Mofi