Re: Errors

90 views
Skip to first unread message

Ralph Heinkel

unread,
Jul 10, 2012, 5:10:52 PM7/10/12
to pyrs...@googlegroups.com
Hi Kyle,

is there a way for me to reproduce your problem? Without any data available it is very hard to see what is going on.

There are ways in Rserve to execute statements without waiting/expecting an answer. I could in principle implement such a functionality, I'm just not clear how the call on the python side should look like.
For a call like 'conn.r.aFunc(some params) this would not work since I cannot possibly know whether 'aFunc' returns something useful or not. In the moment I just return everything I get from Rserve. But I am always open to suggestions.

Cheers,

Ralph

ps: Until Sunday I will be very slow with answering since I only have sporadic access to internet. Next week everything will run smoother again.


Am Montag, 9. Juli 2012 18:39:07 UTC+2 schrieb Kyle Covington:
I'm getting the following error when I try to read a large data.frame.

Error occured in the R session.
Invalid token 0x4a found at lexpos 16, length 16150796


I actually only need to execute the query that creates the data.frame in R and don't need the data itself.

Is it possible to execute a command in R using pyRServe but not to try to process the response, or even to tell R to not return a response?  This is possible in RServe I think.


Thanks

Kyle

Ralph Heinkel

unread,
Nov 30, 2012, 3:08:05 PM11/30/12
to pyrs...@googlegroups.com
Hi Katie,

I'll try this tomorrow (I can see your code snippet) and let you know what I find.

ciao ciao

Ralph

On Friday, November 30, 2012 12:06:11 AM UTC+1, Katie Fisch wrote:
Hi Ralph,

I am having a similar problem. Sometimes I get this error, other times I do not and everything works perfectly, so I suspect it has something to do with the size of the data frame. Below is the error code and a code snippet so that you can try to reproduce the problem (I have also attached the input file that throws the error).  Thanks so much in advance for your help!

Cheers,

Katie

--
Kathleen Fisch, Ph.D.
Postdoctoral Fellow
CA Sea Grant Delta Science Program



CODE SNIPPET
    import pyRserve
    conn = pyRserve.connect(host='localhost', port=6311)
    conn.r('library(kinship2)')
    conn.r('setwd("C:/programming")')
    conn.r('table <- read.table("PedigreeConcatenated.ped")')
    conn.r('closeAllConnections()')
    conn.r('table[,9][table[,4] %in% "M"] <- 1')
    conn.r('table[,9][table[,4] %in% "F"] <- 2')
    conn.r('data <- as.data.frame(table)')
    conn.r('udata <- data[!duplicated(data[,1]),]')
    conn.r('udata.sub <- subset(udata, V11 > 900)')
    conn.r('udata.sub[order(udata.sub[,1]),]')
    conn.r('pedAll <-pedigree(id=udata.sub[,1], dadid=udata.sub[,2], momid=udata.sub[,3], sex=udata.sub[,9])')
    conn.r('kinAll <- kinship(pedAll)')
    print 'Kinship matrix', conn.r.kinAll[1:14, 1:14]
    conn.r('write.csv(kinAll, "kinmatrix.csv")')
    conn.close()


ERROR CODE
Traceback (most recent call last):
  File "C:\Documents and Settings\KFisch\repos\Hatchery Genetic Modeling\src\Kinship.py", line 40, in rKinshipMatrix
    conn.r('kinAll <- kinship(pedAll)')
  File "build\bdist.win32\egg\pyRserve\rconn.py", line 205, in __call__
  File "build\bdist.win32\egg\pyRserve\rconn.py", line 36, in decoCheckIfClosed
  File "build\bdist.win32\egg\pyRserve\rconn.py", line 97, in eval
  File "build\bdist.win32\egg\pyRserve\rparser.py", line 481, in rparse
  File "build\bdist.win32\egg\pyRserve\rparser.py", line 302, in parse
  File "build\bdist.win32\egg\pyRserve\rparser.py", line 321, in _parse
  File "build\bdist.win32\egg\pyRserve\rparser.py", line 327, in _parseExpr
  File "build\bdist.win32\egg\pyRserve\rparser.py", line 169, in nextExprHdr
pyRserve.rtypes.RParserError: Invalid token 0x61 found at lexpos 20, length 14484292

Ralph Heinkel

unread,
Nov 30, 2012, 3:09:51 PM11/30/12
to pyrs...@googlegroups.com
Hi Kyle,

somehow I must have missed your post completely - sorry for that!!
Do you still run into the same problem?
I haven't looked into just executing a command in R without expecting a result, and also I'm not clear how I would setup a syntax for something like this in Python. But proposals are welcome.

ciao ciao

Ralph

Ralph Heinkel

unread,
Dec 2, 2012, 6:33:22 AM12/2/12
to pyrs...@googlegroups.com
Hi Katie,

there is a good and a bad reply at the same time: It works on my machine like a charm:

$ python pedigree.py
Kinship matrix [[ 0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 0.   0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 0.   0.   0.5  0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 0.   0.   0.   0.5  0.   0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 0.   0.   0.   0.   0.5  0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 0.   0.   0.   0.   0.   0.5  0.   0.   0.   0.   0.   0.   0. ]
 [ 0.   0.   0.   0.   0.   0.   0.5  0.   0.   0.   0.   0.   0. ]
 [ 0.   0.   0.   0.   0.   0.   0.   0.5  0.   0.   0.   0.   0. ]
 [ 0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.   0.   0.   0. ]
 [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.   0.   0. ]
 [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.5  0.   0. ]
 [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.5  0. ]
 [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.5]]
heinkel@ralap:~/tmp>

I'm running this on a Linux box, both for R/Rserve and pyRserve, and it creates a CSV file of about 1MB. It also works when I connect from my Mac to my Linux box over LAN. The 'bad' thing with this is that it is hard for me to replicate any intrinsic problem that might only be visible on Windows.

However what I can really do is to implement a feature that one can suppress any results delivered back from Rserve if one doesn't need them. I'll try to implement something like this tomorrow and publish a new version of pyRserve.

ciao ciao and happy greetings from a snowy Black Forest

Ralph

Kathleen Fisch

unread,
Dec 2, 2012, 12:47:14 PM12/2/12
to pyrs...@googlegroups.com
Hi Ralph,

Great, thanks so much for looking into this for me! Perhaps it is a Windows issue.  Part of the time I get the appropriate result, and the other half it throws that error. It's very possible it's a memory thing or other issue, so perhaps suppressing the results will help! I'll try it out after the new release and let you know if it fixes the issue. Thanks again!

Cheers,

Katie

Ralph Heinkel

unread,
Jan 9, 2013, 2:44:38 AM1/9/13
to pyrs...@googlegroups.com
Hi Katie,

when working on my latest version of pyRserve 0.7.0 I found what the problem was with large result sets from R. Please look check my latest post to get a download link for a release candidate of pyRserve 0.7.0, this should fix your problem.

Ralph

Kathleen Fisch

unread,
Jan 9, 2013, 3:46:12 PM1/9/13
to pyrs...@googlegroups.com
Hi Ralph,

Thanks so much for letting me know!  I will download the updated release. Thanks again!

Cheers,

Katie
Reply all
Reply to author
Forward
0 new messages