2008/8/17 Vince Fulco <[EMAIL PROTECTED]>:
> x = robjects.r.rnorm(100)
>
> robjects.r('hist(%s, xlab="x", main="hist(x)")' %repr(x))
>
> Traceback (most recent call last):
>  File "<pyshell#10>", line 1, in <module>
>   robjects.r('hist(%s, xlab="x", main="hist(x)")' %repr(x))
>  File "C:\Python25\Lib\site-packages\rpy2\robjects\__init__.py", line
> 421, in __call__
>   p = self.parse(text=string)
>  File "C:\Python25\Lib\site-packages\rpy2\robjects\__init__.py", line
> 335, in __call__
>   res = super(RFunction, self).__call__(*new_args, **new_kwargs)
> RRuntimeError: Error in function (file = "", n = NULL, text = NULL,
> prompt = "?", srcfile = NULL,  :
>  unexpected input in "hist(c(1.90855727703905, 1.05953538072277,
> 1.81164302718342, -0.156598628840518,
> "
>
> what isn't visible in the above error or the variable x when called is
> that line terminators are displayed.  Are these causing the error
> similar to some pure python instances on WXP?  Have not tried yet on
> linux box.

The example above seems to working on Linux.

Something wrong might be happening during the call to __repr__() and,
as you point it out, have something to do with line terminators.

The code for object representation in robjects is:
def repr_robject(o):
    s = r.deparse(o)
    s = str.join(os.linesep, s)
    return s

The problem you are having suggests that the same line separator is
used by R across
all platforms (no matter what the platform's native separator is).

Can you try the following ?


import rpy2.robjects as robjects


# patch 'repr'
def repr_robject(o):
    s = robjects.r.deparse(o)
    s = str.join('\n', s)
    return s
robjects.repr_robject = repr_robject


x = robjects.r.rnorm(100)
h = robjects.r('hist(%s, xlab="x", main="hist(x)")' %repr(x))




Thanks,


L.




> TIA, Vince
> ###
> System is windows xp sp2
> print(robjects.r)
> <rpy2.robjects.R object at 0x00C522D0>An object of class "simple.list"
>
> $platform
>
> [1] "i386-pc-mingw32"
> $arch
> [1] "i386"
> $os
> [1] "mingw32"
> $system
> [1] "i386, mingw32"
> $status
> [1] ""
> $major
> [1] "2"
> $minor
> [1] "7.1"
> $year
> [1] "2008"
> $month
> [1] "06"
> $day
> [1] "23"
> $`svn rev`
> [1] "45970"
> $language
> [1] "R"
> $version.string
> [1] "R version 2.7.1 (2008-06-23)"
>
>
>
> --
> Vince Fulco, CFA, CAIA
> 612.424.5477 (universal)
> [EMAIL PROTECTED]
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to