diff --git a/DESCRIPTION b/DESCRIPTION index eaca709..c0c2f1b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: common Type: Package -Title: chepec common -Version: 0.0.1.9001 -Description: Commonly used functions and scripts. +Title: solarchemist's collection of common R functions +Version: 0.0.2 +Description: solarchemist's collection of commonly-used R functions and scripts. Authors@R: person("Taha", "Ahmed", email = "taha@chepec.se", role = c("aut", "cre")) License: GPL-3 Encoding: UTF-8 diff --git a/R/common.R b/R/common.R index 52b2598..9d5f982 100644 --- a/R/common.R +++ b/R/common.R @@ -20,12 +20,24 @@ simpleCap <- function(x) { #' Works well when the R-data file contains only ONE variable. #' Not tested for when the R-data file contains more than one variable. #' -#' @param FullPathToRData path to rda file +#' @param path local path to rda file (default) +#' @param url remote URL to rda file (note: requires explicitly specifying argument) #' -#' @return an R object, you will probable want to assign it to a variable +#' @return an R object, you will probably want to assign it to a variable #' @export -LoadRData2Variable <- function(FullPathToRData) { - return(eval(parse(text = load(FullPathToRData)))) +#' @examples +#' \dontrun{ +#' abscoeff <- LoadRData2Variable("/path/file.rda") +#' abscoeef <- LoadRData2Variable(url="http://public.solarchemist/data/file.rda") +#' } +LoadRData2Variable <- function(path, url = "") { + # BEWARE: this function does **not** check for all possible + # variations in the two args. Someone should really improve on that. + if (url == "") { + return(eval(parse(text = load(path)))) + } else { + return(eval(parse(text = load(url(url))))) + } } diff --git a/man/LoadRData2Variable.Rd b/man/LoadRData2Variable.Rd index 7d6f7f8..a8a5f3a 100644 --- a/man/LoadRData2Variable.Rd +++ b/man/LoadRData2Variable.Rd @@ -4,16 +4,24 @@ \alias{LoadRData2Variable} \title{LoadRData2Variable} \usage{ -LoadRData2Variable(FullPathToRData) +LoadRData2Variable(path, url = "") } \arguments{ -\item{FullPathToRData}{path to rda file} +\item{path}{local path to rda file (default)} + +\item{url}{remote URL to rda file (note: requires explicitly specifying argument)} } \value{ -an R object, you will probable want to assign it to a variable +an R object, you will probably want to assign it to a variable } \description{ 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. } +\examples{ +\dontrun{ +abscoeff <- LoadRData2Variable("/path/file.rda") +abscoeef <- LoadRData2Variable(url="http://public.solarchemist/data/file.rda") +} +}