Created
August 27, 2017 01:05
-
-
Save alexpghayes/ece6c686d074b489709d144def510f8a to your computer and use it in GitHub Desktop.
call a python function f: numpy array -> numpy array from R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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