[Python R pyper] Can I use pyper.R inside a function? Solution

If you pass a value to the argument RCMD, an error will occur in pyper.R ...?

In python3, if you type the following in the interpreter, an instance will be created (provided that you are in the path to R)

>>> import pyper
>>> r = pyper.R() 

I got an error when I entered the path to R as below.

>>> import pyper
>>> r = pyper.R(RCMD ="R location")

I could do it without passing it, and I thought it would be okay to leave it alone.

If you do not pass the path to the argument RCMD, you cannot use it in the function ...

I am troubled. Since I'm new to python, I can't figure out what the cause is, so I reread the introductory python3 for the time being. I tried various ways to create a function, but it didn't work ... I was in trouble.

Let's review the error. Let's do so.

Aside from my ignorance, I decided to face the error.

childstderr = file('nul', 'a')

Apparently, this part of pyper.py is doing something wrong. What's wrong?

While I was at a loss, God whispered in my ear

** The function file cannot be used in python3 ... **

No way, there is no way to rearrange file to open. It's not such a simple story. I was skeptical, but

childstderr = open('nul', 'a')

I rewrote it in. Yes, it works fine. Crackling crackling.

Conclusion

The only way to resolve an error is to understand it. It's natural. But I learned python. When I think that it is neither uh nor this, I do not understand enough It's not bad for clarity and detours.

Recommended Posts

[Python R pyper] Can I use pyper.R inside a function? Solution
[Python] I made a function that can also use regular expressions that replace character strings all at once.
I made a familiar function that can be used in statistics with Python
I want to use the R dataset in python
I made a function to crop the image of python openCV, so please use it.
Why can I use the module by importing with python?
Create a function in Python
Use callback function in Python
[Python] Use a string sequence
I made a python text
I made a package that can compare morphological analyzers with Python
I want to use a wildcard that I want to shell with Python remove
I wrote a function to load a Git extension script in Python
[Python] I made an image viewer with a simple sorting function.
I made a shuffle that can be reset (reverted) with Python
[python] I made a class that can write a file tree quickly
[Python] What is a zip function?
Use pymol as a python library
Call a Python function from p5.js.
Can I be a data scientist?
I made a Line-bot using Python!
I made a fortune with Python.
[Python] Make the function a lambda function
Use blender as a python module
A pretty sloppy Python error solution
How to use python zip function
I made a daemon with Python
I made a Docker container to use JUMAN ++, KNP, python (for pyKNP).
I created a template for a Python project that can be used universally
[Python] I made a decorator that doesn't seem to have any use.
[Python] Explains how to use the range function with a concrete example
I made a note of Google colaboratory which can use Spleeter easily.
[Python] I made a utility that can access dict type like a path
[Python] I forcibly wrote a short Perlin noise generation function in Numpy.
A memorandum because I stumbled on trying to use MeCab in Python
Python: I want to measure the processing time of a function neatly
I made a function to see the movement of a two-dimensional array (Python)
I made a module PyNanaco that can charge nanaco credit with python