I use the function toJSON
like this to create a json:
data<-toJSON(list("tablename"= unbox("test.csv"),
"header" = header_df,
"data" = test1
))
the result is the following:
data
{"tablename":"test.csv","header":["PassengerId","Pclass","Name","Sex","Age","SibSp","Parch","Ticket","Fare","Cabin","Embarked"],"data":[["892","3","Kelly, Mr. James","male","34.5","0","0","330911","7.8292","","Q"]]}
The problem is that it is adding double quotes for the PassengerID
and the Age
numbers. If I modify manually the JSON to this:
data<-'{"tablename":"test.csv","header":["PassengerId","Pclass","Name","Sex","Age","SibSp","Parch","Ticket","Fare","Cabin","Embarked"],"data":[[892,"3","Kelly, Mr. James","male",34.5,"0","0","330911","7.8292","","Q"]]}'
then it is working fine. How can I remove the double quotes of some elements in the JSON when creating the JSON?
You can find the input data here:
Hi, you can find it here link I use the following to load it
test <- read.csv("~/Titanic R/test.csv")
header_df<-names(test)
test<-test[1,]
test1<-as.matrix(test)