parent
3f4462aae8
commit
a11f59eb22
@ -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 |
||||
|
@ -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) |
||||
} |
||||
} |
@ -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. |
||||
} |
@ -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() |
||||
} |
Loading…
Reference in new issue