diff --git a/.Rbuildignore b/.Rbuildignore index 8dcb390..2323492 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,3 +4,6 @@ README.html README.Rmd ^cran-comments\.md$ + +cran-comments.md +params.Rproj diff --git a/DESCRIPTION b/DESCRIPTION index fae6553..206a5da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,7 +4,7 @@ Title: Simplify Parameters Description: An interface to simplify organizing parameters used in a package, using external configuration files. This attempts to provide a cleaner alternative to options(). -Version: 0.5.0 +Version: 0.6.1 Depends: R (>= 3.0.2), whisker @@ -20,4 +20,4 @@ Authors@R: c( ) URL: https://github.com/sahilseth/params BugReports: https://github.com/sahilseth/params/issues -RoxygenNote: 5.0.1.9000 +RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index 5aa44a7..1ae6ab2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,7 @@ S3method(print,knitr_kable) S3method(print,opts) export(.load_opts) export(check_args) +export(fix_names) export(get_opts) export(kable) export(load_opts) diff --git a/NEWS.md b/NEWS.md index 8849ee3..529ccfa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,12 +1,16 @@ +p a r a m s 0.6.0 +------------------------------------------------ +- `read_sheet`, now recognizes `.mat` as a tsv + p a r a m s 0.5.0 ------------------------------------------------ -- get_opts output is fully compatible with getOption +- `get_opts` output is fully compatible with getOption - output is a un-named vector, for variable length = 1 p a r a m s 0.4.0 ------------------------------------------------ - updated documentation for read_sheet -- write_sheet now handles multiple extensions +- `write_sheet` now handles multiple extensions p a r a m s 0.3.0 2015/09/22 ------------------------------------------------ diff --git a/R/fix-names.R b/R/fix-names.R new file mode 100644 index 0000000..d55a85e --- /dev/null +++ b/R/fix-names.R @@ -0,0 +1,19 @@ +#' fix_names +#' +#' Replace special characters in column names of a data.frame +#' +#' @param x a vector of column names +#' @param char substitute special char with this. +#' +#' @export +#' +#' @seealso make.names +#' +fix_names <- function (x, char = "."){ + + y <- gsub("_", char, as.character(x)) + y <- gsub(" ", char, as.character(y)) + y <- gsub("\\.", char, as.character(y)) + + return(y) +} diff --git a/R/read-sheet.R b/R/read-sheet.R index a071c6c..6f04e1e 100644 --- a/R/read-sheet.R +++ b/R/read-sheet.R @@ -93,7 +93,7 @@ read_sheet <- function(x, id_column, start_row = 1, sheet = 1, ext, header=TRUE, mat = mat[,!grepl("^X", colnames(mat))] }else{ - stop("Sorry read_shet does not recognize this file format: ", ext, " please use tsv, csv or xlsx (sheetname: sample_sheet)") + stop("Sorry read_sheet does not recognize this file format: ", ext, " please use tsv, csv or xlsx (sheetname: sample_sheet)") } ### ------ remove blank rows and columns diff --git a/R/write-sheet.R b/R/write-sheet.R index 4c87a83..6ba5142 100644 --- a/R/write-sheet.R +++ b/R/write-sheet.R @@ -8,7 +8,7 @@ write_sheet <- function(x, file, ext, ...){ dir.create(dirname(file), recursive = TRUE, showWarnings=FALSE) - if(ext %in% c("tsv", "txt", "conf", "def")){ + if(ext %in% c("tsv", "txt", "conf", "def", "mat")){ write.table(x = x, file = file, sep = "\t", row.names = FALSE, quote = FALSE, ...) }else if(ext=="csv"){ diff --git a/README.md b/README.md index 844b36a..d59440b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ +p a r a m s +------------------ + + [![Build Status](https://travis-ci.org/sahilseth/params.svg)](https://travis-ci.org/sahilseth/params) -[![](http://www.r-pkg.org/badges/version/params)](http://cran.rstudio.com/web/packages/params/index.html) +[![](http://www.r-pkg.org/badges/version/params)](https://cran.r-project.org/package=params) ![](http://cranlogs.r-pkg.org/badges/grand-total/params) **[sahilseth.github.io/params](http://sahilseth.github.io/params)** diff --git a/cran-comments.md b/cran-comments.md index 26aaa59..80105fb 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,8 @@ ## Test environments -* local OS X install, R 3.2.2 -* ubuntu 12.04 (on travis-ci), R 3.2.2 +* local OS X install, R 3.2.4 +* ubuntu 12.04 (on travis-ci), R 3.2.4 * win-builder (release) +* Rdevel version using rocker/r-devel ## Downstream dependencies @@ -10,7 +11,11 @@ of params. + diff --git a/man/fix_names.Rd b/man/fix_names.Rd new file mode 100644 index 0000000..26a5a22 --- /dev/null +++ b/man/fix_names.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fix-names.R +\name{fix_names} +\alias{fix_names} +\title{fix_names} +\usage{ +fix_names(x, char = ".") +} +\arguments{ +\item{x}{a vector of column names} + +\item{char}{substitute special char with this.} +} +\description{ +Replace special characters in column names of a data.frame +} +\seealso{ +make.names +} +