diff --git a/R/laydi/R/laydi.R b/R/laydi/R/laydi.R index 22d1fa3..b6fc85a 100644 --- a/R/laydi/R/laydi.R +++ b/R/laydi/R/laydi.R @@ -27,4 +27,19 @@ write.ftsv <- function(data, con, name="unnamed_dataset", rowdim="rows", coldim= close(con) } +write.laydi.selection <- function(data, con) { + # If con is a file name, open it + opened.here = FALSE + if (is.character(con)){ + con = file(con, "w") + opened.here = TRUE + } + + writeLines(gsub("\\s", "_", data), con=con) + + # If con was a string, close file now + if (opened.here) + close(con) +} + diff --git a/R/laydi/man/laydi-package.Rd b/R/laydi/man/laydi-package.Rd index 5bb3515..8566157 100644 --- a/R/laydi/man/laydi-package.Rd +++ b/R/laydi/man/laydi-package.Rd @@ -18,6 +18,7 @@ LazyLoad: \tab yes\cr library(laydi) write.ftsv(matrix, file, ...) +write.laydi.selection(idlist, file) } \author{ @@ -34,6 +35,4 @@ Maintainer: Einar Ryeng % ~~ \code{\link[:-package]{}} ~~ } \examples{ -library(laydi) -write.ftsv(randu, con="/tmp/randu.ftsv") } diff --git a/R/laydi/man/write.laydi.selection.Rd b/R/laydi/man/write.laydi.selection.Rd new file mode 100644 index 0000000..8558bed --- /dev/null +++ b/R/laydi/man/write.laydi.selection.Rd @@ -0,0 +1,61 @@ +\name{write.laydi.selection} +\alias{write.laydi.selection} +\title{write.laydi.selection} +\description{ +Writes a Laydi selection file from a list of identifiers. Identifiers are +written one per line, with all whitespace characters substituted with +underscores. +} +\usage{ +write.laydi.selection(data, con) +} +\arguments{ + \item{data}{ + A list of identifiers. All whitespace characters will be replaced wity + underscores in the output. (Laydi requires unique identifiers along a + dimension, and does not allow identifiers to contain spaces.) This method + does not ensure that identifiers are unique. + } + \item{con}{ + Connection (or file name) to write the data to. If con is a character + string, it will be treated as a file name, and a file by that name will be + created, written to and closed. If con is an open connection (file descriptor), + the file will remain open. + } +} + +\details{ +%% ~~ If necessary, more details than the description above ~~ +} +\value{ +%% ~Describe the value returned +%% If it is a LIST, use +%% \item{comp1 }{Description of 'comp1'} +%% \item{comp2 }{Description of 'comp2'} +%% ... +} +\references{ +Laydi and the laydi R package are not published in the litterature. Source code +can be found at http://dev.pvv.ntnu.no/projects/laydi +} +\author{ +Einar Ryeng +} +\note{ +%% ~~further notes~~ +} + +%% ~Make other sections like Warning with \section{Warning }{....} ~ + +\seealso{ +%% ~~objects to See Also as \code{\link{help}}, ~~~ +} +\examples{ + +write.laydi.selection(c("sample1", "sample2", "sample3", "/tmp/selected_samples")) + +} + +\keyword{ IO } +\keyword{ file } +