reticulate

Can't find private function for sklearn (LocalOutlierFactor) in reticulate

ぃ、小莉子 提交于 2019-12-24 12:03:17
问题 I tried to add a part of a python code to my R Script. Unfortunately it seems that I can't use a private function for the LocalOutlierFactor in R: # Sample Data n <- 5000 n_outlier <- .05 * n set.seed(11212) inlier <- mvtnorm::rmvnorm(n, mean = c(0,0)) outlier <- mvtnorm::rmvnorm(n_outlier, mean = c(20, 20)) testdata <- rbind(inlier, outlier) smp_size <- floor(0.5 * nrow(testdata)) train_ind <- sample(seq_len(nrow(testdata)), size = smp_size) train_lof <-as.data.frame(testdata[train_ind, ])

python in rmarkdown (reticulate)

落花浮王杯 提交于 2019-12-24 09:59:12
问题 I am trying to add a python chunk in a rmarkdown document. I installed package reticulate then here is my document: ```{r, message=FALSE, warning=FALSE, echo = FALSE} library(reticulate) ``` ```{python, echo = FALSE, eval = FALSE} a=1 a #import numpy as np #import matplotlib.pyplot as plt ## evenly sampled time at 200ms intervals #t = np.arange(0., 5., 0.2) ## red dashes, blue squares and green triangles #plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^') #plt.show() ``` However I get this

Error: Unable to find conda binary. Is Anaconda installed? reticulate Rstudio

梦想的初衷 提交于 2019-12-23 17:32:21
问题 I installed reticulate via Rstudio. Now i want to use conda_create() but I installed anaconda in another directory then the default. How can I change the directory in which Rstudio is searching for anaconda? Error: Unable to find conda binary. Is Anaconda installed? 回答1: The directory should be in your path. But you can check where it is like this: Sys.which("python") If you have multiple python versions (or it is not in your path), then you can specify a different location with use_python

Use reticulate to call Python script and send email

不想你离开。 提交于 2019-12-11 18:53:34
问题 I use Windows Task Scheduler to run an R Script several times a day. The script transforms some new data and adds it to an existing data file. I want to use reticulate to call a Python script that will send me an email listing how many rows of data were added, and if any errors occurred. This works correctly when I run it line by line from within RStudio. The problem is that it doesn't work when the script runs on schedule. I get the following errors: Error in py_run_file_impl(file, local,

Qt platform plugin issue Rstudio

£可爱£侵袭症+ 提交于 2019-12-10 20:25:00
问题 I am trying to do a seaborn heatmap plot via RStudio. I use reticulate package in R. Below is my code: library(reticulate) use_condaenv("python36", conda = "auto", required = FALSE) os <- import("os") os$listdir(".") py_available() sns <- import('seaborn') plt <- import('matplotlib.pyplot') pd <- import('pandas') dat <- AirPassengers # convert time series to data frame dat <- data.frame(matrix(dat, ncol=frequency(dat), dimnames=dimnames(.preformat.ts(dat)) )) dat sns$heatmap(r_to_py(dat), fmt

Reticulate not sharing state between R/Python cells or Python/Python cells in RMarkdown

扶醉桌前 提交于 2019-12-08 17:06:09
问题 I'm trying to get Reticulate working in RMarkdown , per the setup instructions. However, I am unable to share state between separate Python cells or Python and R cells, as the docs indicate I should be able to. Here is my setup and output: Cell 1 (Setup): {r} library(reticulate) path_to_python <- "/Users/User/anaconda3/bin/python" use_python(path_to_python) knitr::knit_engines$set(python = reticulate::eng_python) py_available(initialize = TRUE) Output: [1] TRUE Cell 2 (set variable in Python)

ModuleNotFoundError: No module named 'rpytools' while using reticulate library

ⅰ亾dé卋堺 提交于 2019-12-08 07:35:49
问题 Hi this is my first stackoverflow question so sorry in advance for any mistakes. I am trying to start playing with R reticulate library. I have installed the package, and tried to import os Python module. Everything seemed to be ok, but then while I start typing for example os$listdir R throws this error: Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'rpytools' . Here is my entire code: install.packages("reticulate") library(reticulate) os <-

Unable to change python path in reticulate (R)

瘦欲@ 提交于 2019-11-30 20:28:13
The first lines I run when launching my rstudio session are: library(reticulate) use_python("/usr/local/lib/python3.6/site-packages") However, when I run py_config() it shows as still using the default python 2.7 installation. This is an issue b.c I'm unable to import any modules that were installed for python3. Any idea why this isn't working? I followed documentation fairly closely. I observed that neither the technique "use_python('path')" nor the tactic of Sys.setenv(RETICULATE_PYTHON = 'path') in .RProfile worked for me (of course I am sure it must have worked for others.) In any case the

Unable to change python path in reticulate (R)

大憨熊 提交于 2019-11-30 02:58:46
问题 The first lines I run when launching my rstudio session are: library(reticulate) use_python("/usr/local/lib/python3.6/site-packages") However, when I run py_config() it shows as still using the default python 2.7 installation. This is an issue b.c I'm unable to import any modules that were installed for python3. Any idea why this isn't working? I followed documentation fairly closely. 回答1: I observed that neither the technique "use_python('path')" nor the tactic of Sys.setenv(RETICULATE

Importing python module in R

怎甘沉沦 提交于 2019-11-28 13:39:36
I am trying to import a python module in R using the reticulate package. The module can be found here . I cloned the repository and ran python setup.py install which ran successfully. If I open a python shell, I'm able to import debot . However, when I try to import it in RStudio, I get the following error: dbot=import("debot") Error in py_module_import(module, convert = convert) : ImportError: No module named debot I am on macOS Sierra version 10.12.6 and installed python 3.6 through Anaconda. I have also tried giving the path to python as: path_to_python <- "/anaconda/bin/python3.6" use