Reputation: 51
I am making a number of calculations from a dataset and I want to display the end results in a structured and ordered way in a txt document.
So far I have tried something which is really messy but it kinda works (see below), but I'm sure there are better and more elegant solutions. When using cbind, I get the [,1] [,2] etc labels on top of my data and I don't need them in my output.
id = c(1, 2,3,4)
age = c(10, 12, 14, 17)
gender = c("m", "f", "m", "f")
dataset = data.frame (id,age, gender)
attach (dataset)
space = "+++++++++++++++++++++++++++++++"
print1 = summary (dataset)
print2 = cbind("age oldest student", max(age))
printfull = capture.output(print1, space, print2, space)
write.table(printfull, "C:/Users/me/Desktop/dataset123.txt")
Thanks
Upvotes: 0
Views: 931
Reputation: 5184
You can use RJSONIO to convert your r objects into json
library('RJSONIO')
toJSON(list(list(1,2,3),1,2,4:5))
Upvotes: 1