Hi,
I use rpy on linux to call R functions. Works fine up to the following
problem: How to parse arrays (no vectors, that means 2-dimensional) to
R without much effort?
The following code solves the problem (in two different ways).
However, it seems to me that there might be a way to do it more
efficiently.
rpy.r.assign("N ", N)
rpy.r("A2 <- array(1:N^2, dim=c(N,N))")
rpy.r("A3 <- array(1:N^2, dim=c(N,N))")
for i in range(N): # two alternative ways to parse
arrays
rpy.r.assign("W i", W[i])
rpy.r.assign("i ", i+1)
rpy.r("""for( j in 1:N ){
A2[i,j] <- Wi[j]}""")
for k in range(N):
rpy.r.assign("k ", k+1)
rpy.r("A3[i,k] <- Wi[k]")
print rpy.r("A3")
print rpy.r("A2")
As I see it, the problem is, that the 'assign' command works only
either for scalars or vectors (one-dimensional arrays but not more-
dimensional arrays). I tried it for 2-dimensional arrays and the
result is a list whose components are vectors. Again, this is easy to
convert to a two-dimensional array but the point here is that one has
to do it.
Maybe there are people using R with python who have some more
experience. I would be interested how they solved this problem.
Thanks!
Frank 0 1098 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: malv |
last post by:
Did anybody manage to use pairs() or coplot() from python using the rpy
module?
In fact any information going a bit beyond Tim Churches' very useful
examples on plot() usage in rpy would be highly welcome.
Thx.
malv
|
by: Bo Peng |
last post by:
Dear list,
I am using rpy, a python module to control statistical package R from
python. Running the following commands
>>> from rpy import *
>>> r.plot(0)
will pass command 'plot' to R and run it. I notice that the R-plot will
not refresh (a window is created but the figure is not drawn) until the
|
by: jason |
last post by:
Hello:
I installed the following:
python-2.4.2.msi
pywin32-207.win32-py2.4.exe
R-2.2.1-win32.exe
rpy-0.4.6-R-2.0.0-to-2.2.1-py24.win32.exe
on a Windows XP (SP2) box.
|
by: libiger |
last post by:
Hi,
I am trying to perform multiple regression in python using rpy.
I can get it to work for two arrays, however when I try to regress a matrix and an array (as in the following code) I get an error message (below.)
Can someone please help?
Thanks,
Ondrej
|
by: Frank |
last post by:
Hi,
I use rpy to plot functions and have the following problem. When I
execute the following code line by line (start python and then execute
line by line) the resulting figure looks as it should. However, when I
put these lines in a script and execute the script the figure appears
for half a second but then crashes. Using pylab.show() at the end of
the script prevents the crash but now the window is no longer
refreshed (e.g., changing...
| |
by: hnessenospam |
last post by:
Howdy, I've been using rpy (1.0.1) and python (2.5.1) on my office
computer with great success. When I went to put rpy on my laptop,
however, I get an error trying to load rpy.
"Unable to determine R version from the registry. Trying another
method."
followed by a few lines of the usual error message style (ending with
"NameError: global name 'RuntimeExecError' is not defined." I have
reinstalled R (now 2.6.1), rpy, and python...
|
by: tkpmep |
last post by:
I'm running Python 2.5.2 on Windows XP and need to interface with R,
so I downloaded the R 2.6.2 statistical package and installed it, and
did the same for RPy 1.02 (i made sure I got the version for Python
2.5 and R 2.62.). When I go to the Python command line and type
I get the following error message:
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
from rpy import *
|
by: tkpmep |
last post by:
I have just installed R and Rpy, and am experiencing an odd problem
when driving R from Python - if I create a plot in R, the portion of
the plot window that lies under the IDLE window in which I type my
Python code remains blank. So if I type
I get a plot of y vs. x, but only the top right portion of the plot
shows any points, axes etc. The bottom left corner (the portion that
lay under the IDLE window) is blank. Is this a known...
|
by: Mike P |
last post by:
Hi experts,
I've just seen there is an R module, what i can't see easily is if you
can / how to import other modules for R into the Rpy module
Can anyone advise on this?
Cheers
Mike
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |