new functionality: musoGetValues, musoCompareFiles
This commit is contained in:
parent
2607a19741
commit
9bb19a3336
@ -20,7 +20,9 @@ export(getFilesFromIni)
|
||||
export(getyearlycum)
|
||||
export(getyearlymax)
|
||||
export(multiSiteCalib)
|
||||
export(musoCompareFiles)
|
||||
export(musoDate)
|
||||
export(musoGetValues)
|
||||
export(musoGlue)
|
||||
export(musoMapping)
|
||||
export(musoMappingFind)
|
||||
|
||||
@ -31,3 +31,38 @@ changeByIndex <- function (rowIndex, parameter, fileStringVector){
|
||||
fileStringVector[i] <- changeNth(fileStringVector[i], h, parameter)
|
||||
fileStringVector
|
||||
}
|
||||
|
||||
|
||||
#' musoGetValues
|
||||
#'
|
||||
#' Get values from a musofile by supplying muso indices
|
||||
#'
|
||||
#' @param filename The name of the musofile we want the value from (e.g. epc file)
|
||||
#' @param indices muso indices
|
||||
#' @usage musoGetValues(filename, indices)
|
||||
#' @export
|
||||
|
||||
musoGetValues <- function(filename, indices){
|
||||
sapply(indices, function(index){
|
||||
colIndex <- round((index*100) %% 10) + 1
|
||||
rowIndex <- as.integer(index)
|
||||
as.numeric(unlist(strsplit(readLines(filename)[rowIndex],split="\\s+"))[colIndex])
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
#' musoCompareFiles
|
||||
#'
|
||||
#' A simple wrapper function based on musoGetValues where you can get multiple values from multiple files
|
||||
#' using the supplied indices. It is useful for comparing files.
|
||||
#'
|
||||
#' @param filenames The name of the files where you can get the data from
|
||||
#' @param indices muso indices
|
||||
#' @usage musoCompareFiles(filenames, indices)
|
||||
#' @export
|
||||
|
||||
musoCompareFiles <- function(filenames, indices){
|
||||
sapply(filenames, function(fn){
|
||||
musoGetValues(fn,indices)
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user