Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Entire Results from R

by haukex (Archbishop)
on Feb 21, 2019 at 09:14 UTC ( [id://1230285]=note: print w/replies, xml ) Need Help??


in reply to Entire Results from R

Your use of $R->set() is incorrect: to set multiple values, you have to pass an arrayref: $R->set( 'data', ["2016-03-15 13","2016-03-16 23","2016-03-17 06","2016-03-18 15","2016-03-19 08","2016-03-20 21"] ); Then the code works for me.

Replies are listed 'Best First'.
Re^2: Entire Results from R
by kevbot (Vicar) on Feb 22, 2019 at 06:36 UTC
    ++haukex I put together a short script to confirm that your solution works (I was curious about Statistics::R since I had not used it before). This code,
    #!/usr/bin/env perl use Statistics::R; use Data::Dumper; # Create a communication bridge with R and start R my $R = Statistics::R->new(); $R->set( 'data', [ "2016-03-15 13", "2016-03-16 23", "2016-03-17 06", "2016-03-18 15", "2016-03-19 08", "2016-03-20 21" ] ); $R->run( q`datevec <- strptime(data,"%Y-%m-%d %H")` ); $R->run( q`xx <- difftime(datevec[-length(datevec)],datevec[-1],units= +"hours")` ); @Rres = $R->get('xx'); print Dumper(\@Rres); exit;
    Gives this output,
    $VAR1 = [ [ '[1]', '-34', '-7', '-33', '-17', '-37' ] ];

      Thanks for the example! I also submitted a pull request that adds a "too many arguments" error to ->set.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1230285]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2025-05-19 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.