开发者

Calling software modules (Java, Perl, etc.) from R

I've recently started using R for Natural Language Processing tasks and find that a lot of applications are available in Java and Perl (for my purposes).

For example: A few perl modules are available to find distance measures between words by querying Wordnet. I am aware of the R Wordnet package, but it does not perform the tasks that these CPAN modules do. Many Java packages for NLP are out there, which I'd like to use from within R.

I know of rJava, RSPerl, the simple system command amongst others, but I'd like more examples of how I could make calls to Java and Perl applications from R.

Recently I tried capturing console output from a perl script.

cat( 'print "Hello World\n";',file="hello.pl" )

system(command="c:\\Perl64\\bin\\perl hello.pl")

system(command=paste(Sys.getenv("COMSPEC"),"/c","C:\\Perl64\\bin\\perl hello.pl"))

None of the above system commands showed 'Hello World' on the R console. I've used "system" before to run perl scripts to开发者_Python百科 perform tasks without wanting to capture console output.

Any hints and redirection to other more extensive sources of information would be highly appreciated.

Thank you


If you read help(system) you should find an option you need to change. I believe but you will see in Windows differs slightly from what I have on Linux, but consider

R> system("echo Hello")
Hello 
R> system("echo Hello", intern=TRUE)
[1] "Hello"
R> 

The second one is different -- now the text became a character variable in R. This is what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜