LoadRData2Variable() now accepts URLs. Bumped version number.

master
Taha Ahmed 4 years ago
parent 38db263a39
commit 5f4f884043

@ -1,8 +1,8 @@
Package: common Package: common
Type: Package Type: Package
Title: chepec common Title: solarchemist's collection of common R functions
Version: 0.0.1.9001 Version: 0.0.2
Description: Commonly used functions and scripts. Description: solarchemist's collection of commonly-used R functions and scripts.
Authors@R: person("Taha", "Ahmed", email = "taha@chepec.se", role = c("aut", "cre")) Authors@R: person("Taha", "Ahmed", email = "taha@chepec.se", role = c("aut", "cre"))
License: GPL-3 License: GPL-3
Encoding: UTF-8 Encoding: UTF-8

@ -20,12 +20,24 @@ simpleCap <- function(x) {
#' Works well when the R-data file contains only ONE variable. #' Works well when the R-data file contains only ONE variable.
#' Not tested for when the R-data file contains more than 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 #' @export
LoadRData2Variable <- function(FullPathToRData) { #' @examples
return(eval(parse(text = load(FullPathToRData)))) #' \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)))))
}
} }

@ -4,16 +4,24 @@
\alias{LoadRData2Variable} \alias{LoadRData2Variable}
\title{LoadRData2Variable} \title{LoadRData2Variable}
\usage{ \usage{
LoadRData2Variable(FullPathToRData) LoadRData2Variable(path, url = "")
} }
\arguments{ \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{ \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{ \description{
This function loads R-data file into a variable instead of into the workspace. 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. Works well when the R-data file contains only ONE variable.
Not tested for when the R-data file contains more than 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")
}
}

Loading…
Cancel
Save