From nalimilan at club.fr  Mon Oct 24 19:28:55 2011
From: nalimilan at club.fr (Milan Bouchet-Valat)
Date: Mon, 24 Oct 2011 19:28:55 +0200
Subject: [Rd] strsplit convert data
In-Reply-To: <1319452277838-3932704.post@n4.nabble.com>
References: <1319452277838-3932704.post@n4.nabble.com>
Message-ID: <1319477336.8217.1.camel@milan>

Le lundi 24 octobre 2011 ? 03:31 -0700, RMSOPS a ?crit :
> 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)
Hm, that code triggers many errors. What's the problem you'd like help
on? You can't reasonably expect people to fix all of your code... ;-)



[Rd] strsplit convert data
Milan Bouchet-Valat