From ricardosousa2000 at clix.pt  Mon Oct 24 12:31:17 2011
From: ricardosousa2000 at clix.pt (RMSOPS)
Date: Mon, 24 Oct 2011 03:31:17 -0700 (PDT)
Subject: [Rd] strsplit convert data
Message-ID: <1319452277838-3932704.post@n4.nabble.com>


I am using the following code but I do not know the debug and run for
 correct errors

 library (tcltk)


 file <-tclvalue (tkgetOpenFile ())
   if (nchar (file))
   {
     tkmessageBox ("Select the file")
   }
 else
   {
     tkmessageBox (message = paste ("Was select file", file))
     Dataset <- read.table (file, header = FALSE, sep = "", na.strings =
"NA", dec =".", strip.white = TRUE)
      Dataset
 }

 input <- readLine (Dataset)
 input
 close (Dataset)
 input <- gsub ('*','', input)
 in.s <- strsplit (input, '')
 id <- sort (unique (unlist (in.s)))

 # Create the output matrix
  output <- matrix (0, ncol = length (id), nrow = length (in.s))
  colNames (output) <- id

  for (i in seq_along (in.s)) {
      output [i, unlist (in.s [[i]])] <- 1
  }
  
 write.csv (output, file = res.csv)

 Thanks















--
View this message in context: http://r.789695.n4.nabble.com/strsplit-convert-data-tp3932704p3932704.html
Sent from the R devel mailing list archive at Nabble.com.



[Rd] strsplit convert data
RMSOPS