How to disable R from changing the "-" character into '.' character when writing to a file? -


i want write results of table file , names of columns contain '-' character, when write file replaces '-' '.'.

function(result,path) {   num<-0   for(i in 1:length(result[,1]))   {      if(length(which([result[i,]>0))>0)     {        temp<-which(result[i,]>0)]        val<-paste(names(temp),sep="\n")        write(val,file=paste(path,"/result",num,".txt",sep=""))        num<-num+1      }   } } 

do 1 know how disable option?

my column names names of proteins of them written in way yer060w-a

thank in advance.

it takes special care make such entity. can use col.names argument , assign colnames(dfrm) it.

> tst <- data.frame(`a-b`= letters[1:10], `1-2`=1:10, check.names=false) > colnames(tst) [1] "a-b" "1-2" > write.table(tst, file="tst.txt", col.names=colnames(tst) ) 

pasted editor:

"a-b" "1-2" "1" "a" 1 "2" "b" 2  snipped rest... 

no success write.table? see write() doesn't have same repertoire of options write.table. let's make array (rather dataframe) dim names having "-"'s:

dctest <- array(1:27, c(3,3,3)) dimnames(dctest) <- list(dim1 =c(a="a-b",b="b-c",c="c%d"),                           dim2=letters[4:6],                           dim3= letters[7:9]) 

one quick way output capture.output():

capture.output(dctest, file="testm.txt") 

testm.txt looks in editor:

, , dim3 = g       dim2 dim1  d e f   a-b 1 4 7   b-c 2 5 8   c%d 3 6 9  , , dim3 = h       dim2 dim1   d  e  f   a-b 10 13 16   b-c 11 14 17   c%d 12 15 18  , , dim3 =       dim2 dim1   d  e  f   a-b 19 22 25   b-c 20 23 26   c%d 21 24 27 

you should not forget capture output has append= parameter if wanted append successive slices through array.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -