Search Results

Search found 6 results on 1 pages for 'rpy2'.

Page 1/1 | 1 

  • Converting python objects for rpy2

    - by bgbg
    The following code is supposed to created a heatmap in rpy2 import numpy as np from rpy2.robjects import r data = np.random.random((10,10)) r.heatmap(data) However, it results in the following error Traceback (most recent call last): File "z.py", line 8, in <module> labRow=rowNames, labCol=colNames) File "C:\Python25\lib\site-packages\rpy2\robjects\__init__.py", line 418, in __call__ new_args = [conversion.py2ri(a) for a in args] File "C:\Python25\lib\site-packages\rpy2\robjects\__init__.py", line 93, in default_py2ri raise(ValueError("Nothing can be done for the type %s at the moment." %(type(o)))) ValueError: Nothing can be done for the type <type 'numpy.ndarray'> at the moment. From the documentation I learn that r.heatmap expects "a numeric matrix". How do I convert np.array to the required data type?

    Read the article

  • How to suppress error messages in rpy2

    - by Björn
    Hello! The following code does not work. It seems that the R warning message raises a python error. # enable use of python objects in rpy2 import rpy2.robjects.numpy2ri import numpy as np from rpy2.robjects import r # create an example array a = np.array([[5,2,5],[3,7,8]]) # this line leads to a warning message, which in turn raises an # error message if run within a script. result = r['chisq.test'](a) Running that code example in ipython works, however, running it inside a script raises the errorTypeError: 'module' object is unsubscriptable. I assume this is due to the warning message. What is the best way to avoid this problem? Thanks in advance!

    Read the article

  • rpy2: Converting a data.frame to a numpy array

    - by Mike Dewar
    I have a data.frame in R. It contains a lot of data : gene expression levels from many (125) arrays. I'd like the data in Python, due mostly to my incompetence in R and the fact that this was supposed to be a 30 minute job. I would like the following code to work. To understand this code, know that the variable path contains the full path to my data set which, when loaded, gives me a variable called immgen. Know that immgen is an object (a Bioconductor ExpressionSet object) and that exprs(immgen) returns a data frame with 125 columns (experiments) and tens of thousands of rows (named genes). robjects.r("load('%s')"%path) # loads immgen e = robjects.r['data.frame']("exprs(immgen)") expression_data = np.array(e) This code runs, but expression_data is simply array([[1]]). I'm pretty sure that e doesn't represent the data frame generated by exprs() due to things like: In [40]: e._get_ncol() Out[40]: 1 In [41]: e._get_nrow() Out[41]: 1 But then again who knows? Even if e did represent my data.frame, that it doesn't convert straight to an array would be fair enough - a data frame has more in it than an array (rownames and colnames) and so maybe life shouldn't be this easy. However I still can't work out how to perform the conversion. The documentation is a bit too terse for me, though my limited understanding of the headings in the docs implies that this should be possible. Anyone any thoughts?

    Read the article

  • Strange Problem with RPy2

    - by jrara
    Hello, After installing RPy2 from http://rpy.sourceforge.net/rpy2.html I'm trying to use it in Python 2.6 IDLE but I'm getting this error: >>> import rpy2.robjects as robjects >>> robjects.r['pi'] <RVector - Python:0x0121D8F0 / R:0x022A1760> What I'm doing wrong?

    Read the article

  • Plotting 3-tuple data points in a surface / contour plot using matplotlib

    - by morpheous
    I have some surface data that is generated by an external program as XYZ values. I want to create the following graphs, using matplotlib: Surface plot Contour plot Contour plot overlayed with a surface plot I have looked at several examples for plotting surfaces and contours in matplotlib - however, the Z values seems to be a function of X and Y i.e. Y ~ f(X,Y). I assume that I will somehow need to transform my Y variables, but I have not seen any example yet, that shows how to do this. So, my question is this: given a set of (X,Y,Z) points, how may I generate Surface and contour plots from that data? BTW, just to clarify, I do NOT want to create scatter plots. Also although I mentioned matplotlib in the title, I am not averse to using rpy(2), if that will allow me to create these charts.

    Read the article

  • Best way to build an application based on R?

    - by Prasad Chalasani
    I'm looking for suggestions on how to go about building an application that uses R for analytics, table generation, and plotting. What I have in mind is an application that: displays various data tables in different tabs, somewhat like in Excel, and the columns should be sortable by clicking. takes user input parameters in some dialog windows. displays plots dynamically (i.e. user-input-dependent) either in a tab or in a new pop-up window/frame Note that I am not talking about a general-purpose fron-end/GUI for exploring data with R (like say Rattle), but a specific application. Some questions I'd like to see addressed are: Is an entirely R-based approach even possible ( on Windows ) ? The following passage from the Rattle article in R-Journal intrigues me: It is interesting to note that the first implementation of Rattle actually used Python for implementing the callbacks and R for the statistics, using rpy. The release of RGtk2 allowed the interface el- ements of Rattle to be written directly in R so that Rattle is a fully R-based application If it's better to use another language for the GUI part, which language is best suited for this? I'm looking for a language where it's relatively "painless" to build the GUI, and that also integrates very well with R. From this StackOverflow question How should I do rapid GUI development for R and Octave methods (possibly with Python)? I see that Python + PyQt4 + QtDesigner + RPy2 seems to be the best combo. Is that the consensus ? Anyone have pointers to specific (open source) applications of the type I describe, as examples that I can learn from?

    Read the article

1