Browse Source

Added function simpleCap()

master
TA 4 years ago
parent
commit
a11f59eb22
  1. 9
      DESCRIPTION
  2. 1
      NAMESPACE
  3. 29
      R/AddColumn2Data-nm2eV.R
  4. 16
      R/common.R
  5. 1
      man/AVS2SHE.Rd
  6. 18
      man/AddColumnEnergy.Rd
  7. 1
      man/Celsius2Kelvin.Rd
  8. 1
      man/ConvertRefPot.Rd
  9. 1
      man/ConvertRefPotEC.Rd
  10. 1
      man/ExtractSampleIdString.Rd
  11. 1
      man/GenericXtableSetAttributes.Rd
  12. 1
      man/Kelvin2Celsius.Rd
  13. 1
      man/LoadRData2Variable.Rd
  14. 1
      man/LongtableXtableHeader.Rd
  15. 1
      man/ProvideSampleId.Rd
  16. 1
      man/RefCanonicalName.Rd
  17. 1
      man/SHE2AVS.Rd
  18. 1
      man/SubfigureGenerator.Rd
  19. 1
      man/SubstrateHistory.Rd
  20. 1
      man/TabularXtableHeader.Rd
  21. 1
      man/as.SHE.Rd
  22. 1
      man/as.degrees.Rd
  23. 1
      man/as.radians.Rd
  24. 1
      man/int2padstr.Rd
  25. 1
      man/is.wholenumber.Rd
  26. 1
      man/molarity2mass.Rd
  27. 1
      man/numbers2words.Rd
  28. 1
      man/potentials.as.SHE.Rd
  29. 1
      man/roundup.Rd
  30. 18
      man/simpleCap.Rd
  31. 1
      man/siunitx.uncertainty.Rd
  32. 1
      man/thth2d.Rd
  33. 1
      man/trapz.Rd
  34. 1
      man/wavelength2num.Rd
  35. 1
      man/wavenum2length.Rd

9
DESCRIPTION

@ -1,10 +1,13 @@
Package: common
Type: Package
Title: chepec common
Version: 0.0.0.9004
Version: 0.0.0.9005
Description: Commonly used functions and scripts.
Authors@R: person("Taha", "Ahmed", email = "taha@chepec.se", role = c("aut", "cre"))
License: GPL-3
LazyData: TRUE
RoxygenNote: 5.0.1
Imports: xtable
RoxygenNote: 6.0.1
Imports:
xtable,
utils,
photoec

1
NAMESPACE

@ -23,6 +23,7 @@ export(molarity2mass)
export(numbers2words)
export(potentials.as.SHE)
export(roundup)
export(simpleCap)
export(siunitx.uncertainty)
export(thth2d)
export(trapz)

29
R/AddColumn2Data-nm2eV.R

@ -0,0 +1,29 @@
#' AddColumnEnergy
#'
#' A poorly documented function.
#' To be honest I don't remember what it's for. Not exported.
#'
#' @param path.to.folder full path to folder containing data files
#'
#' @return Writes to file.
AddColumnEnergy <- function(path.to.folder) {
txt.files <-
list.files(path = path.to.folder, pattern = "\\.txt$",
full.names = TRUE)
# message(txt.files)
for (f in 1:length(txt.files)) {
this.file <- txt.files[f]
# read the file contents into df
this.data <-
utils::read.table(this.file, header = T,
col.names = c("wavelength", "intensity"))
# add energy (eV) as third column
this.data$energy <- photoec::wavelength2energy(this.data$wavelength)
# message(head(this.data))
utils::write.table(this.data,
file = this.file,
sep = "\t",
col.names = c("#Wave", "#Intensity", "#Energy"),
row.names = FALSE)
}
}

16
R/common.R

@ -1,3 +1,19 @@
#' Capitalise first letter in each word in string
#'
#' Copied verbatim from https://stackoverflow.com/a/6364905
#' Also see R doc of base::toupper()
#'
#' @param x string of one or more words
#'
#' @return string
#' @export
simpleCap <- function(x) {
s <- strsplit(x, " ")[[1]]
paste(toupper(substring(s, 1, 1)), substring(s, 2),
sep = "", collapse = " ")
}
#' LoadRData2Variable
#'
#' This function loads R-data file into a variable instead of into the workspace.

1
man/AVS2SHE.Rd

@ -15,4 +15,3 @@ potential in SHE scale (numeric)
\description{
Converts from absolute vacuum scale (AVS) to SHE scale
}

18
man/AddColumnEnergy.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AddColumn2Data-nm2eV.R
\name{AddColumnEnergy}
\alias{AddColumnEnergy}
\title{AddColumnEnergy}
\usage{
AddColumnEnergy(path.to.folder)
}
\arguments{
\item{path.to.folder}{full path to folder containing data files}
}
\value{
Writes to file.
}
\description{
A poorly documented function.
To be honest I don't remember what it's for. Not exported.
}

1
man/Celsius2Kelvin.Rd

@ -15,4 +15,3 @@ Kelvin (numeric)
\description{
Converts temperature from Celsius to Kelvin.
}

1
man/ConvertRefPot.Rd

@ -19,4 +19,3 @@ potential in output reference scale (numeric)
\description{
Convert from one electrochemical scale to another
}

1
man/ConvertRefPotEC.Rd

@ -23,4 +23,3 @@ SHE: standard hydrogen electrode
Ag/AgCl: silver silver-chloride electrode (3M KCl)
SCE: saturated calomel electrode
}

1
man/ExtractSampleIdString.Rd

@ -16,4 +16,3 @@ sampleid (character string)
Extract sampleid from a string by utilising the fact that samepleid's
adhere to a defined format.
}

1
man/GenericXtableSetAttributes.Rd

@ -39,4 +39,3 @@ xtabWithAttributes <- GenericXtableSetAttributes(xtobject)
xtabWithAttributes <- GenericXtableSetAttributes(xtobject, nxtdigits = c(0, 2, 2, 4))
}
}

1
man/Kelvin2Celsius.Rd

@ -15,4 +15,3 @@ degrees Celsius (numeric)
\description{
Converts from temperature in Kelvin to degrees Celsius
}

1
man/LoadRData2Variable.Rd

@ -17,4 +17,3 @@ This function loads R-data file into a variable instead of into the workspace.
Works well when the R-data file contains only ONE variable.
Not tested for when the R-data file contains more than one variable.
}

1
man/LongtableXtableHeader.Rd

@ -21,4 +21,3 @@ This function creates a longtable header assuming
that the LaTeX document will use the booktabs package.
This function should not be used together with \code{booktabs = TRUE}
}

1
man/ProvideSampleId.Rd

@ -20,4 +20,3 @@ The second arg is optional, defaults to "old" behaviour,
but can be set to "dirname" for another behaviour.
The second arg was added so as not to break older code.
}

1
man/RefCanonicalName.Rd

@ -22,4 +22,3 @@ by not requiring them to remember a particular label or name for each reference
electrode, instead almost any sufficiently distinct label or string will still
be correctly identified.
}

1
man/SHE2AVS.Rd

@ -15,4 +15,3 @@ potential in AVS scale (numeric)
\description{
Converts from SHE scale to absolute vacuum (AVS) scale
}

1
man/SubfigureGenerator.Rd

@ -30,4 +30,3 @@ Generate LaTeX subfigure code for a bunch of supplied image paths,
subcaptions, label and subfigure layout.
Supports splitting the figures over several pages or using landscape layout.
}

1
man/SubstrateHistory.Rd

@ -17,4 +17,3 @@ a dataframe
\description{
Display the history of a substrate (sampleid)
}

1
man/TabularXtableHeader.Rd

@ -17,4 +17,3 @@ character string (with LaTeX escaping)
\description{
This function should be used together with \code{booktabs = TRUE}.
}

1
man/as.SHE.Rd

@ -27,4 +27,3 @@ potential in SHE scale
Convert an arbitrary number of potentials against any known electrochemical
scale (or the electronic vacuum scale) to potential vs SHE.
}

1
man/as.degrees.Rd

@ -15,4 +15,3 @@ degrees (numeric)
\description{
Convert from radians to degrees
}

1
man/as.radians.Rd

@ -15,4 +15,3 @@ radians (numeric)
\description{
Convert from degrees to radians
}

1
man/int2padstr.Rd

@ -20,4 +20,3 @@ a string or a vector of strings
Converts an integer or a vector of integers to a string
of fixed length padded with a specified character (e.g., zeroes).
}

1
man/is.wholenumber.Rd

@ -19,4 +19,3 @@ I am not even sure this function is useful any longer.
Kept for legacy purposes just in case some old code depends on it.
This function was copied from R's documentation (see ?is.integer).
}

1
man/molarity2mass.Rd

@ -21,4 +21,3 @@ You want to prepare a solution of known molarity and volume of
a particular substance.
This function calculates the required mass to weigh up.
}

1
man/numbers2words.Rd

@ -26,4 +26,3 @@ Original author: John Fox, Department of Sociology, McMaster University, Hamilto
http://cran.csiro.au/doc/Rnews/Rnews_2005-1.pdf
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/46843.html
}

1
man/potentials.as.SHE.Rd

@ -25,4 +25,3 @@ This function just outputs a tidy dataframe with potential vs SHE for
different scales, electrolytes, concentrations, and temperatures.
Using data from literature.
}

1
man/roundup.Rd

@ -18,4 +18,3 @@ a number
This function rounds UP to the nearest interval specified by "nearest"
http://stackoverflow.com/questions/6461209/how-to-round-up-to-the-nearest-10-or-100-or-x
}

18
man/simpleCap.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/common.R
\name{simpleCap}
\alias{simpleCap}
\title{Capitalise first letter in each word in string}
\usage{
simpleCap(x)
}
\arguments{
\item{x}{string of one or more words}
}
\value{
string
}
\description{
Copied verbatim from https://stackoverflow.com/a/6364905
Also see R doc of base::toupper()
}

1
man/siunitx.uncertainty.Rd

@ -19,4 +19,3 @@ a string suitable for use with siunitx num{} command
\description{
Writing number with exponent (such as scientific notation) with uncertainty using siunitx
}

1
man/thth2d.Rd

@ -17,4 +17,3 @@ d-spacings (numeric)
\description{
This function applies Bragg's law to calculate d-spacings from thth (n = 1)
}

1
man/trapz.Rd

@ -18,4 +18,3 @@ vector (of length n - 1)
Numerically calculate area under an arbitrary curve (defined by x, y coord pairs)
using trapezodial integration. See Wikipedia for more info on trapz integration.
}

1
man/wavelength2num.Rd

@ -17,4 +17,3 @@ Converts wavelength (nm) to wavenumber (cm-1)
Only valid for absolute wavelengths, NOT delta wavelengths (ranges)
http://www.powerstream.com/inverse-cm.htm
}

1
man/wavenum2length.Rd

@ -17,4 +17,3 @@ Converts wavenumber (cm-1) to wavelength (nm)
Only valid for absolute wavenumbers, NOT delta wavenumbers (ranges)
http://www.powerstream.com/inverse-cm.htm
}

Loading…
Cancel
Save