Frank Gibbons
2002-Jun-13 15:42 UTC
[R] Using RSPerl with add-on package ctest and named parameters
Hi,. I've installed RSPerl on my Linux box. It runs all of the test scripts that I've been able to find. I've learned that I can pass in vectors of data as array-refs, and can use named parameters with R::callWithNames and a hash of names and values. The one problem that I'm left with is how to call a function from an add-on package ('ctest' in this case). I know that I need to use R::library("ctest") to load the library. I want to run the following R code from Perl: > library(ctest) > x <- c(1.83, .50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3) > y <- c(0.878, 0.647, 0.598, 2.95, 1.06, 1.29, 1.06, 3.14, 1.29) > wilcox.test(x, y, paired=TRUE, alternative = "greater") Wilcoxon signed rank test data: x and y V = 36, p-value = 0.06445 alternative hypothesis: true mu is greater than 0 I had thought that this should do the job: #!/usr/bin/perl use strict; R::library("RSPerl"); R::library("ctest"); my @x = (1.83, .50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3); my @y = (0.878, 0.647, 0.598, 2.95, 1.06, 1.29, 1.06, 3.14, 1.29); R::callWithNames('wilcox.test', {'', \@x, '', \@y, 'alternative', "greater"}); The problem is, it doesn't complain, it doesn't return anything at all. Shouldn't it print out the results just like the R code does, or does it return them in an array? I tried catching the return value, by assigning to a scalar, but get an error: /usr/bin/perl: relocation error: /usr/lib/R/library/RSPerl/share/local/lib/perl/5.6.1/auto/R/R.so: undefined symbol: userLevelConversionToPerl I know I'm using the right name ('wilcox.test'), since trying other variations ('wilcox', 'ctest::wilcox') gives me an error message. I'd really appreciate any suggestions for this problem. I've scoured the web, and haven't been able to find any examples in which an add-on package function is called using the RSPerl module. Thanks, Frank Gibbons PhD, Computational Biologist, Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA 02115, USA. Tel: 617-432-3555 Fax: 617-432-3557 http://llama.med.harvard.edu/~fgibbons -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Frank Gibbons
2002-Jun-13 15:54 UTC
[R] Using RSPerl with add-on package ctest and named parameters
At 11:41 AM 6/13/2002, you wrote:> > The problem is, it doesn't complain, it doesn't return anything at all. > > Shouldn't it print out the results just like the R code does, or does it > >It would if you called print() on the return value (which is not a >scalar).Brian, I tried that already, and get the same result as if I had tried assigning to a scalar (see below). Can you suggest something else? Do you know for sure that it should return a value (rather than printing out its own results)? If so, is there possibly a problem with my installation of R.so, the library mentioned in the error message, which is apparently unable to find the symbol to convert the result (whatever it is) to Perl? Thanks for your help, Frank> > return them in an array? I tried catching the return value, by assigning to > > a scalar, but get an error: > > > > /usr/bin/perl: relocation error: > > /usr/lib/R/library/RSPerl/share/local/lib/perl/5.6.1/auto/R/R.so: undefined > > symbol: userLevelConversionToPerlPhD, Computational Biologist, Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA 02115, USA. Tel: 617-432-3555 Fax: 617-432-3557 http://llama.med.harvard.edu/~fgibbons -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._