In [ ]:
!pip install rpy2 --upgrade
!pip install --upgrade pandas
!pip install singledispatch
In [ ]:
from rpy2.rinterface import R_VERSION_BUILD
print(R_VERSION_BUILD)
In [ ]:
from rpy2.robjects import r
In [ ]:
print "Hello World!"
In [ ]:
str_list = ['This', 'is', 'python!']
str_list
In [ ]:
# Para cada elemento i dentro do range de 0 até o tamanho da string, faça o print do elemento i
for i in range(0, len(str_list)):
print str_list[i],
In [ ]:
def my_function(i):
print "I've been called", i + 1, "times!"
In [ ]:
for i in range(0, 5):
my_function(i)
In [ ]:
#R Session
In [ ]:
r('print("Hello World!")')
In [ ]:
r('str_list <- c("This", "is", "R!")')
r('for (i in 1:length(str_list)){print(str_list[i])}')
In [ ]:
r('''
my_function <- function(i){
cat("I've been called", i, "times!\n")
}''')
r('for (i in 1:5) {my_function(i)}')
In [ ]:
from numpy import *
import scipy as sp
from pandas import *
from rpy2.robjects.packages import importr
import rpy2.robjects as ro
import pandas.rpy.common as com
In [ ]:
# Load dataset from R
ro.r('data(mtcars)')
In [ ]:
# Load data and store inside some python object
pydf = com.load_data('mtcars')
In [ ]: