Subject: | Statistics::R problem with R to Perl arrays |
Date: | Wed, 21 Dec 2011 13:15:24 -0800 |
To: | "bug-Statistics-R [...] rt.cpan.org" <bug-Statistics-R [...] rt.cpan.org> |
From: | Tom Keller <kellert [...] ohsu.edu> |
#!perl -w
use strict;
use 5.012;
use Carp;
use Data::Dumper;
use Statistics::R;
my $R = Statistics::R->new();
my $cmds = <<EOF;
x = (0:9)
for (i in x)
ifelse( i > 6, break, print(i) )
EOF
my $outR1 = $R->run($cmds);
say join(", ", $outR1);
say "i = 10 has value ", $R->get('x[10]');
my $original = $R->get('x');
say join(", ", @{$original});
say "i = 10 has value $$original[10]";
say Dumper $original;
#############
The machine: $ uname -a
Darwin thomass-imac.ohsu.edu<http://thomass-imac.ohsu.edu> 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
$ perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-multi-2level
This code gives:
[1] 0
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
i = 10 has value 9
0, 1, 2, 3, 4, 5, 6, 7, 8 9
Use of uninitialized value in concatenation (.) or string at /Users/kellert/Computing/Perl-repos/Scripts/R_ex02.pl line 23.
i = 10 has value
$VAR1 = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8 9'
];
logout
[Process completed]
#########
thanks,
Thomas (Tom) Keller, PhD
kellert at ohsu.edu<http://ohsu.edu/>
503.494.2442
6588 R Jones Hall (BSc/CROET)
MMI DNA Services<http://www.ohsu.edu/xd/research/research-cores/dna-analysis/>
Member of OHSU Shared Resources<http://www.ohsu.edu/xd/research/research-cores/index.cfm>