Moving between R and Python¶
The Python and R packages share analytical concepts and function names wherever the languages permit. The goal is familiar workflows, not byte-for-byte API identity.
Common conventions¶
Concept |
Python |
R |
|---|---|---|
Package alias |
|
|
Output selector |
|
|
Data frame |
|
|
Plot |
Matplotlib, Seaborn, or Plotly object |
ggplot object |
Missing value |
|
|
Python uses return_type because return is a reserved keyword. Supported
values are documented per function and generally mirror the corresponding R
function.
Equivalent example¶
Python:
import vivainsights as vi
data = vi.load_pq_data()
result = vi.create_bar(
data,
metric="Collaboration_hours",
hrvar="Organization",
return_type="table",
)
R:
library(vivainsights)
data <- pq_data
result <- create_bar(
data,
metric = "Collaboration_hours",
hrvar = "Organization",
return = "table"
)
Intentional differences¶
Python follows Python naming and keyword rules.
Plot object types differ between ecosystems.
Python functions generally return pandas objects; R functions generally return data frames or tibbles.
A function available in one package may arrive later in the other.
When porting an analysis, first match the function’s analytical purpose and selected columns, then account for these language-specific differences.