Here's my python module:
#!/usr/bin/python
import rpy2.robjects as robjects
import MySQLdb as mdb
import json
import rpy2.robjects.vectors as ro
r= robjects.r
class Deviation:
def __init__(self):
print("Standard Deviation")
def s_deviation(self):
con = mdb.connect('localhost', 'root', 'devil', 'data')
cursor = con.cursor()
cursor.execute("SELECT * FROM traffic")
rows = cursor.fetchall()
rows = list(rows)
a = [x[1] for x in rows]
result = ro.IntVector(a)
a = r.sd(result)
print a
def deviation():
dev = Deviation()
deviation = dev.s_deviation()
The function deviation() from this module when called returns the result as R vector. How do I make this return the result as Json objects? Thank you!