How to use the variable from the python in rpy2?

First, make two lists from your database. Something like: cursor = con.cursor() cursor.execute(“SELECT * FROM traffic”) #Retrieves data from SQL rows = cursor.fetchall() Month = list() Traffic = list() for row in rows: Month.append(row[‘Month’]) # guesswork – what does a row look like? Traffic.append(row[‘Traffic’]) Then, now you have two python lists, you can make a … Read more

Replace specific characters within strings

With a regular expression and the function gsub(): group <- c(“12357e”, “12575e”, “197e18”, “e18947”) group [1] “12357e” “12575e” “197e18” “e18947” gsub(“e”, “”, group) [1] “12357” “12575” “19718” “18947” What gsub does here is to replace each occurrence of “e” with an empty string “”. See ?regexp or gsub for more help.

How to make a great R reproducible example

Basically, a minimal reproducible example (MRE) should enable others to exactly reproduce your issue on their machines. A MRE consists of the following items: a minimal dataset, necessary to demonstrate the problem the minimal runnable code necessary to reproduce the error, which can be run on the given dataset all necessary information on the used … Read more