I just tried something similar and got something sensible, as follows:
set.seed(1) e1 <- array(1:6, dim=c(3,2), dimnames=list(NULL, LETTERS[1:2])) e2 <- array(rnorm(6), dim=c(3,2), dimnames=list(NULL, letters[1:2])) e12 <- cor(e1, e2) e12. <- round(e12)
sink("e12.txt") e12. sink()
#####################
File "e12.txt" contained the following:
a b A 0 -1 B 0 -1
An alternative is the following:
write.table(e12., "e12.csv", quote=FALSE)
File "e12.csv" contained the same as *.txt.
Are your names actually "A", "B", etc., or do they include long character strings? If the latter, that would explain what you got. If the former, what do you get from "options()$width"? I suspect it may be some small number.
hope this helps. spencer graves
p.s. Did you read the posting guide, "http://www.R-project.org/posting-guide.html"? If you had followed that more carefully, especially regarding supplying a real, simple example with a few lines that would illustrate your problem, you would have gotten a quicker answer. p.p.s. I found "options()$width" from "www.r-project.org" -> search -> "R site search" -> "output line width". It was in the sixth hit.
Srinivas Iyyer wrote:
Dear Group, I am calculating correlation coeff.
between two populations. After calculating the
cor.coefs I want to represent them as a matrix file.
a b c d
A 1 0 1 1
B 1 1 1 1 C 1 0 1 0
D 0 1 1 1
could any one please help me how can i acheive this:
dim(e1)[1] 22283 60
dim(e2)[1] 22283 158
sink("old_new.txt")
round(cor(cbind(e1,e2),use="complete.obs"))
sink()
Currently this is the way my result looksL a A 1 B 1 C 1 D 0 b A 0 B 1 C 0 D 1
I want to see my result as:
a b c d
A 1 0 1 1
B 1 1 1 1 C 1 0 1 0
D 0 1 1 1
thankyou srini
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html