Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Revered Monks,

I am trying to use Statistics::R to run a simple t-test, but I am having a hard time feeding the data to R from my perl script.

Below is a minimal script. $data is created by the first 100 lines of my perl script, which I removed here.

use strict; use warnings; use Statistics::R; my $data = "Subj Cond Count subj1 high 13 subj1 low 15 subj2 high 12 subj2 low 15 subj3 high 16 subj3 low 17 subj4 high 11 subj4 low 18 "; my $R = Statistics::R->new(); $R->startR; #$R->send(qq`data = scan()\n$data\n\n`); #my $r_output = $R->read; #print $r_output . "\n"; $R->stopR();

Using "scan" does not work. The example in the documentation is too simple, it only contains one number. Also, I do not understand what the qq, q and backticks are in the argument of "send" in the documentation.

Normally in R I would run the following commands, but I would like to avoid writing the data out to a file and reading it back in.

example=read.table("file.txt", header = TRUE) t.test(Count~Cond, data = example) wilcox.test(Count~Cond, data = example)

If per chance someone uses the package, I would be grateful for any help. I am an R beginner so there may be ways of reading in data I do not know about.


In reply to Feed data to R using Statistics::R by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-19 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found