How To Use The Variable From The Python In Rpy2?
My simple program extracts the database from Python and store in the variable row. cursor = con.cursor() cursor.execute('SELECT * FROM traffic') #Retrieves data fro
Solution 1:
First, make two lists from your database. Something like:
cursor= con.cursor()
cursor.execute("SELECT * FROM traffic")
#Retrieves data fromSQLrows= cursor.fetchall()
Month= list()
Traffic = list()
forrowinrows:
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 plot thus:
>>>r.plot(Month,Traffic)
rpy2.rinterface.NULL
You maybe want lines:
>>>r.plot(Month,Traffic,type="l")
rpy2.rinterface.NULL
You maybe want nice labels:
>>>r.plot(Month,Traffic,type="l",xlab="Month",ylab="Traffic")
Post a Comment for "How To Use The Variable From The Python In Rpy2?"