I started to use google Colab but would prefer to do it in RStudio.
In Colab keyboard shortcuts don't work, there is no environment pane, etc.
I would be grateful for any hints how to use it in RStudio.
I have got R dataframe - do I need to convert it to Python's dataframe somehow, when I want to do something with it in Python? Does the same apply to vector ?
If I have R object saved as RDS or RData - will Python recognize it ?
What does actually reticulate do ? Helping to connect R and Python ?
Is there R to Python "translator", eg. I know how to do something in R, I want to have it translated into Python's code ? Is it possible ?
Does the tidyverse's pipe exist in Python ?
About making plots: is it like in R, I mean: ggplot(Iris, "rest of the code") or Python's plot is being build step by step by adding and running next, additional lines od code ?
No, objects are stored in separate environments but you can access R objects from within Python code using the r object (e.g. r.x would access to x variable created within R from Python).
You usually would read it in R and access the content in Python as explained above. Still, it s possible that a Python library I'm unaware of exists that allows reading directly from these formats.
From the documentation:
Reticulate embeds a Python session within your R session, enabling seamless, high-performance interoperability.
I'm not aware of such a tool but that doesn't mean it doesn't exist.
There is no tidyverse in Python since it is an R package but very likely there are Python libraries implementing similar functionality.
Python, like R, is open-source with a lot of independent contributors, so functionalities depend on the specific library you are using, there are plotting libraries based on ggplo2 like this one for example:
For this I can say that chatGPT is a good tools, but not is perfect. Im try in occasion but not is 100 % perfect. Is a tool for start with basics things.
Put in chatGPT this and see the results: make a histogram in R and python.
This is not code translation per se, it is freely creating code in both languages to accomplish the same task but it is not translating one into the other.
There is "serving" dataframe in R. There is no R package called distfit. There is a distfit package in Python. What to do next , what would be the best way to do it in RStudio ?
Yes, it is, thank you. This output looks a bit messy, is it possible to put it in like broom:tidy or something to get that output in more orderly way ?
I understand from that code of yours and output as well, that whilst writing in *.py file in R we change R library to Python's import and Python's dot to R $ ? Is it correct ?
One more question, does Python recognize R objects ? I mean I want mtcars in Python, how do I convert it to Python's dataframe ?
I suppose it is, but I have never worked with that specific python library and it's output so me finding out how is pretty much the same as you finding out how on your own. Have in mind that I'm importing Python modules into R so the output is just an R object.
I think I don't understand what you mean, if you write code in a .py file it means you are writing Python code, ergo, you have to use Python syntax which is completely independent from R.
reticulate makes interoperability possible, when you are importing python modules into R (like I did in my example) the data sharing is transparent to the user but if you are writing Python code you can access R objects trough the special r object (as long as you are running Python using reticulate) so it would be something like r.mtcars, given that mtcars is already loaded into the global environment of the R session.
I must have mixed up something, but what I meant was for example that in R there is library(tidyverse), but in Python we do have import pandas, in R it was written up there in your post:
dfit$fit_transform(X)
but in Python it is:
dfit.fit_transform(X)
This is what I meant, apologies for confusion as this is all new to me.
Thank you for your kind replies.