Skip to content

Commit

Permalink
Merge pull request #36 from jasenfinch/devel
Browse files Browse the repository at this point in the history
v0.5.8
  • Loading branch information
jasenfinch committed Nov 17, 2021
2 parents 61fdebf + e3c5343 commit 73f5cef
Show file tree
Hide file tree
Showing 31 changed files with 457 additions and 274 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: metaboMisc
Title: Miscellaneous Functions for Metabolomics Analyses
Version: 0.5.7
Version: 0.5.8
Authors@R: person("Jasen", "Finch", email = "jsf9@aber.ac.uk", role = c("aut", "cre"))
Description: Miscellaneous helper functions for metabolomics analyses that do not yet have a permanent home.
URL: https://jasenfinch.github.io/metaboMisc
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -83,6 +83,7 @@ importFrom(profilePro,processingParameters)
importFrom(profilePro,technique)
importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_df)
importFrom(readr,write_csv)
importFrom(stats,IQR)
importFrom(stats,quantile)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# metabMisc 0.5.8

* Numbers of characters in strings are now limited by `sanitiseTable()`.

# metaboMisc 0.5.7

* Removed `aberHRML/metaboData` from the Remotes field in the DESCRIPTION to ensure that the CRAN version of metaboData is installed.
Expand Down
19 changes: 17 additions & 2 deletions R/sanitise.R
@@ -1,21 +1,36 @@
#' Sanitise a data table
#' @description Sanitise a data table by restricting the number of rows and rounding numeric columns.
#' @description Sanitise a data table by restricting the number of rows or characters and rounding numeric columns.
#' @param x A tibble or data.frame containing the data to be sanitised
#' @param maxRows Maximum number of rows with which to restrict the table
#' @param sigFig Significant figures with which to round numeric columns
#' @param maxCharacters Maximum number of characters allowed in a string before it is truncated
#' @examples
#' sanitiseTable(iris,maxRows = 10,sigFig = 1)
#' @importFrom dplyr mutate_if
#' @importFrom purrr map_df
#' @export


sanitiseTable <- function(x,maxRows = 5000,sigFig = 3){
sanitiseTable <- function(x,maxRows = 5000,sigFig = 3,maxCharacters = 100){
x <- mutate_if(x,is.numeric,signif,digits = sigFig)

if (nrow(x) > maxRows){
message(str_c('Number of rows in table restricted to ',maxRows,'.'))
x <- x[seq_len(maxRows),]
}

a <- map_df(x,~{
if (typeof(.x) == 'character'){
limit_characters <- .x %>%
nchar() %>%
{. > maxCharacters}

.x[limit_characters] <- str_sub(.x[limit_characters],1,maxCharacters) %>%
str_c(.,'...')
}

return(.x)
})

return(x)
}
2 changes: 1 addition & 1 deletion _pkgdown.yml
@@ -1 +1 @@
url: https://jasenfinch.github.io/metaboMisc/
url: https://jasenfinch.github.io/metaboMisc/
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Expand Up @@ -2,7 +2,7 @@ pandoc: 2.11.4
pkgdown: 1.6.1
pkgdown_sha: ~
articles: {}
last_built: 2021-09-27T10:19Z
last_built: 2021-11-17T09:52Z
urls:
reference: https://jasenfinch.github.io/metaboMisc//reference
article: https://jasenfinch.github.io/metaboMisc//articles
Expand Down
Binary file modified docs/reference/Rplot002.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/addAssignments.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/convertSampleInfo.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 39 additions & 20 deletions docs/reference/detectBatchDiff.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 73f5cef

Please sign in to comment.