Skip to content

Instantly share code, notes, and snippets.

@alexpghayes
Created August 27, 2017 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpghayes/ece6c686d074b489709d144def510f8a to your computer and use it in GitHub Desktop.
Save alexpghayes/ece6c686d074b489709d144def510f8a to your computer and use it in GitHub Desktop.
call a python function f: numpy array -> numpy array from R
library(reticulate)
library(tidyverse)
X <- rbind(
c(1, 2),
c(3, 4)
)
y <- cbind(
c(3, 5)
)
main <- py_run_file("scratch.py")
main$f(X, y)
X %*% y
import numpy as np
def f(X, y):
return np.dot(X, y), 2 * y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment