[R] spacing problems

mohamed nur anisah nuranisah_mohamed at yahoo.com
Sun Jan 20 15:13:56 CET 2008


Dear all,
   
  I try to do a matrix with this data but the warning massage had occur:
  In matrix(x5, ncol = 6, byrow = T) :
  data length [116] is not a sub-multiple or multiple of the number of rows [20]
   
  I think the spacing problem cause this where double spacing and tabs are everywhere!! 
   
  Secondly, I have a raw data (which i downloaded from the AutoGraph server) where it has 2 data in one text file. How am i going to split it to two?? I also need to make a command function so that  i can do it for the other 38 similar types of data. Below show my command function and attach with is my data. Kindly help me to solve these problems and thanks in advance.
   
  fun<-function(filename)
{
 x<-scan(file=filename,sep="\n",skip=12,what=character(0))
 x1<-gsub("[][)(:\\,|\\-]","",x)
 x2<-gsub("Telomere","NA",x1)
 x3<-gsub("Decreasing order|Increasing order","",x2)
 x4<-strsplit(x3,"\t")
 x5<-unlist(x4)
 y<-matrix(x5,ncol=6,byrow=T)
 tc<-textConnection(apply(y,1,paste,collapse=" "))
 w<-read.table(tc)
 t<-as.data.frame(w)
 attr(t,"names")=c("CS(O)","id","no.anchor","ref","loc.start","loc.end","CS(O).size","CS(O)ref.density","tested","loc.start","loc.end","breakp.start","breakp.end","den of anchor")
 return(t)
 }
   
   
  Cheers,
  Anisah


       
---------------------------------
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ch1.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20080120/887c441a/attachment.txt 


More information about the R-help mailing list