r

Split string column to multiple columns in R/Python

Split string column to multiple columns in R/Python Question: I’m trying to split the following string str = "A (B) C, D (E) F, G, H, a (b) c" into 9 separate strings like: A, B, C, D, E, {F, G, H}, a, b, c I’ve tried str = "A (B) C, D (E) F, …

Total answers: 1

NA_character_ not identidied as NaN after importing it into Python with rpy2

NA_character_ not identidied as NaN after importing it into Python with rpy2 Question: I am using the following code inside a R magic cell: %%R -o df library(tibble) df <- tibble(x = c("a", "b", NA)) However, when I run in another cell (a Python one): df.isna() I get x 1 False 2 False 3 False …

Total answers: 1

How to create polygon from bbox data in python?

How to create polygon from bbox data in python? Question: I have created a code in R which extracts bbox from a list of points and then creates a polygon using st_as_sfc. Now I am trying to do the same in python where I was able to get the bbox coordinates from the list of …

Total answers: 2

Facing issues when running a shiny app for Python locally

Facing issues when running a shiny app for Python locally Question: I want to run shiny app for python locally. The following code works like a charm: cd/d D:/app1 py from shiny import run_app run_app() However, when I try the following code, it does not work. cd/d D: py from shiny import run_app run_app("app1:app") Any …

Total answers: 1

pythonic equivalent of R double pivot and filter

pythonic equivalent of R double pivot and filter Question: A task I come up against reasonable often is something like the following transformation: from: home_team_id away_team_id home_team away_team 1 1 2 Arsenal Tottenham 2 2 3 Tottenham Chelsea to team value 1 Arsenal 1 2 Tottenham 2 3 Tottenham 2 4 Chelsea 3 in my …

Total answers: 1

What is the equivalent of .loc with multiple conditions in R?

What is the equivalent of .loc with multiple conditions in R? Question: I wonder if there is any equivalent of .loc in R where I am able to have multiple condition that would work in a for loop. In python I accomplished this using .loc as seen in the code below. However, I am unable …

Total answers: 1

How to order a nested list in R

How to order a nested list in R Question: I need the code to be in R Exemple I have a list: [[0,’A’,50.1], [1,’B’,50.0], [2,’C’,50.2], [3,’D’,50.7], [4,’E’,50.3]] I want to order it based on the 3rd elemnts only so I get a result like this [[1,’B’,50.0], [0,’A’,50.1], [2,’C’,50.2], [4,’E’,50.3], [3,’D’,50.7]] and then reorder the index …

Total answers: 1

How to combine columns into a new table – Python or R

How to combine columns into a new table – Python or R Question: Scenario: If I have this table, let’s call it df: survey_answer_1___1 survey_answer_1___2 survey_answer_1___3 survey_answer_2___1 survey_answer_2___2 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 1 1 0 0 Using R or Python, how do I …

Total answers: 5

ERROR, The integral is probably divergent

ERROR, The integral is probably divergent Question: Haii guys, i have problem with code in R i wanna running the integral code, but the code its doesnt work. is there anyone can help me? retensi = 1136074 b = 1/1.230219e-07 sx = function(x) {exp(-x/b)} integrate(sx, retensi, Inf) when i run this code, the ruslt is …

Total answers: 2