In Rmarkdown access with R code to Py objet?

Hi community, Im want to access a data scraped with Py code in Rmarkdwon but with R.

Im try with py.df1 but show error. Im want make a web scraping with Py and make R basics plots with Tidyverse.

title: "Scraping py"
author: "M.Acosta"
date: "`r Sys.Date()`"
output: html_document

import pandas as pd
import requests
from io import StringIO 
url = ""

# Send a GET request and remove the comment tags from response text
stripped_comment_tags = StringIO(requests.get(url).text.replace('<!--', '').replace('-->', ''))

df1 = pd.read_html(stripped_comment_tags, attrs={'id': 'stats_squads_keeper_for'})[0]
df2 = pd.read_html(stripped_comment_tags, attrs={'id': 'stats_keeper'})[0]

# Print data frames
print(df1) # run well
print(df2) # run well
datos = py$df1  # Error
#datos = py$df1 Error: object 'py' not found


Im find the solution in this chapter:


Im forget put this in the first R chunk {r, setup}

```{r, setup}

I'm add this all run well.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.