This question is similar to R: Format output of write.table, and 42-'s answer works except I need to remove row names. capture_output doesn't seem to have an equivalent of row.names = FALSE. I've also tried row.names(aa) <- NULL prior to running capture.output, but that doesn't help.
Is it possible to generate a right-justified text file just like capture.output does below, but with no row names?
aa = matrix(c(1000,110,10,1,
0,2000,20,2,
30,300,3000,30000), nrow=3, byrow=TRUE,
dimnames = list(NULL, c("C1", "C2", "C3","C4")))
aa<-as.data.frame(aa)
aa
capture.output( print(aa, print.gap=3), file="capture.txt")
write.fwf doesn't right-justify as desired:
write.fwf(aa, "fwf.txt", rownames=FALSE, sep="\t", quote=FALSE, justify = "right")
Thank you!
row.names=Fin yourprintstatement? For example:capture.output( print(aa, print.gap=3, row.names = F), file="capture.txt")