[R] Variables in a Tabular form. easily saved in a txt file

arun smartpink111 at yahoo.com
Thu Jul 26 14:28:07 CEST 2012


HI,

Not sure if this is what you are looking for.

Try:
dat1<-read.table(text="
     Postal Code | Superb
City1   |   2134          |  2
City2   |   254            |  5
City3   |   12              |  54433
",sep="|",header=TRUE) 


 Postal.Code1<-paste0("|",dat1$Postal.Code)
Supertb1<-paste0("|",dat1$Superb)
 dat2<-data.frame(Postal.Code=Postal.Code1,Superb=Supertb1)
 rownames(dat2)<-rownames(dat1)
write.table(dat2,"dat6.txt",quote=FALSE)
#saving it as table format in html
library(xtable)
print(xtable(dat1),type="html",file="clipboardnew")

#another way to save it on plot.
library(plotrix)

 plot(0:3,0:3,xlab="",ylab="",type="n",axes=FALSE)
 addtable2plot(1,1,dat1,cex=1)




A.K.



----- Original Message -----
From: Alaios <alaios at yahoo.com>
To: R help <R-help at r-project.org>
Cc: 
Sent: Thursday, July 26, 2012 7:29 AM
Subject: [R] Variables in a Tabular form. easily saved in a txt file

Dear all,
I would like to save few variable-names with their values in a tabular form, with that I mean

that files can be printed easily in R in a tabular form and also saved in a ascii file that when one opens it see also the variables in a nice tabular format.

IS that possible? Below a small example of how should look results in R and in a txt file.






             Postal Code | Superb
City1   |   2134          |  2
City2   |   254            |  5
City3   |   12              |  54433



I am ok if you can give me some hard coded example to try. 



Regards
Alex
    [[alternative HTML version deleted]]


______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list