Factor-analysis,
print(fa1, digits = 2, cutoff = 0.5, sort = TRUE)
shows me a nice table in the console. How can I save this table to a CSV file?
I tried write.csv
and write.table
with various combinations of arguments, but all gave the wrong result.
This works:
fa1 <- factanal(x, 3, rotation="varimax")
sink("tp.txt") #write all output to file tp.txt
print(fa1, digits=2, cutoff=.5, sort=FALSE);
sink() #stop sinking, =sink(NULL)
However, I want all values/numbers separated by commas.
Thanks Tim, sorry if this is a duplicate, but answering a question with another method that I cannot understand doesn't help. I don't want to redirect output to a variable, but to a CSV file. capture.output
is not what I am looking for.
Thanks dcarlson! Not sure how to make your suggestion work. Is there a way to pipe the output to RMarkdown and then use a knit function?