Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Feed data to R using Statistics::R

by pvaldes (Chaplain)
on Feb 24, 2013 at 23:36 UTC ( #1020439=note: print w/replies, xml ) Need Help??


in reply to Feed data to R using Statistics::R

data = scan()$data

Not, this is not how R works, try something like

data <- scan(file =$filehandle)

And you need also avoit to mix the headers with the data

my $data = "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 <- read.table($data, header = false), sep = "")`); R->send(qq`names(data) <- c("Subj","Cond","Count")`); R->send(qq`attach(data)`); R->send(qq`$Cond <- as.factor($Cond)`);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020439]
help
Chatterbox?
[mz2255]: Tried again, denied. Maybe my code is just so bad the site refuses to post it.
[marto]: no, there's a bug, sometimes...
[mz2255]: ok, well thanks for looking into it. I'll try again later.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2017-10-19 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (255 votes). Check out past polls.

    Notices?