r-package

Add objects to package namespace

微笑、不失礼 提交于 2019-11-27 11:07:35
I'd like to push a function inside a package namespace so it can access internal objects of that package (let's use stats package as an example). I've tried using myfun <- function(x) print(x) env = loadNamespace("stats") assign("myfun", myfun , env) But it is locked. So I've tried to unlock my object unlockBinding("myfun", env) Since myfun doesn't exist yet, I can't unlock it. Any help ? Mark Bravington Along the line of @Hadley's solution, but using the environment of the namespace, how about: environment(myfun) <- asNamespace('stats') Why not just set the environment of your new function to

HTTP error 400 on google_elevation() call

試著忘記壹切 提交于 2019-11-27 07:21:12
问题 I am using the R-package googleway to decode polylines using decode_pl and subsequently getting the elevation data at the corresponding lat/lon coordinates using google_elevation . I get the polylines from Strava, using the rStrava package. Sample polylines: pl1 <- "q{|aHknlv@n@Mt@IxAGb@B\\Eb@AZGRG^W`AyAPQF?NHDJFZBz@FVNPn@D`@C|@DjACv@@h@Dh@Ll@Zj@^\\`@fAx@j@r@d@n@\\ZJPNd@NbANzAFhANb@JNLHD?PKHMRGPSr@UPMXGDGJELMFCPAbBWROpAm@h@YZe@dAaC@Of@aAb@a@t@iALg@LWNQROf@IjAJnFbAv@Dr@Aj@BpBx@fFdCd@HlAHd@Pp@b

How can I document data sets with roxygen?

邮差的信 提交于 2019-11-27 03:11:10
Is it possible to include .R files in the data directory of my package in the roxygen process? I have put several .R files in the data directory. When they are sourced with data(), they read in raw data files and perform some transformations. Roxygen can be used anywhere within an R file (in other words, it doesn't have to be followed by a function). It can also be used to document any docType in the R documentation. So you can just document your data in a separate block (something like this): #' This is data to be included in my package #' #' @name data-name #' @docType data #' @author My

Creating a local R package repository

Deadly 提交于 2019-11-27 00:14:21
I would like to create a local R package repository such that users in my company can install packages from it and the system admins can update the local repo periodically. Access to the CRAN mirrors is currently denied. Is there a simple way to do this? Dirk Eddelbuettel Yes, either a copy of CRAN or a repo with local packages is easy to set up. Presumably you want this for Windows so do this: Create a top-level directory on your webserver, say R/ Create the usual hierarchy in there: R/bin/windows/contrib/2.11 . If you need to support other (earlier) releases, simply create directories 2.10 ,

Can't download data from Yahoo Finance using Quantmod in R

最后都变了- 提交于 2019-11-26 22:25:07
I'm trying to download data from Yahoo using this code: library(quantmod) getSymbols("WOW", auto.assign=F) This has worked for me in the past in every occasion except now, 5 days before my group assignment is due. Except now I receive this error: Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot download all files In addition: Warning message: In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : URL 'https://ichart.finance.yahoo.com/table.csv? s=WOW&a=0&b=01&c=2007&d=4&e=17&f=2017&g=d&q=q&y=0&z=WOW&x=.csv': status was '502 Bad Gateway' The

Problems with installation R packages

风格不统一 提交于 2019-11-26 19:55:16
问题 Im windows user. A few weeks ago I installed R and Rstudio and installed many packages. Today there was a spell that new packages are not installed. Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib: cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES' I reinstalled R but this did not solve the problem. Warning in install.packages : InternetOpenUrl failed: 'Can not connect to server' 回答1: This is something that pops up in R and

How to load packages in R automatically?

两盒软妹~` 提交于 2019-11-26 18:26:00
Could you suggest me a way for loading packages in R automatically? I mean, I want to start a session in R without needing to use library('package name') several times. Suppose I downloaded all packages I'll want to use the next time I start R. Put library(foo) in your .Rprofile file or set R_DEFAULT_PACKAGES : see ?Rprofile ... In particular (because ?Rprofile is long and potentially intimidating): If you want a different set of packages than the default ones when you start, insert a call to ‘options’ in the ‘.Rprofile’ or ‘Rprofile.site’ file. For example, ‘options(defaultPackages =

How can I document data sets with roxygen?

穿精又带淫゛_ 提交于 2019-11-26 17:59:13
问题 Is it possible to include .R files in the data directory of my package in the roxygen process? I have put several .R files in the data directory. When they are sourced with data(), they read in raw data files and perform some transformations. 回答1: Roxygen can be used anywhere within an R file (in other words, it doesn't have to be followed by a function). It can also be used to document any docType in the R documentation. So you can just document your data in a separate block (something like

Show names of everything in a package

末鹿安然 提交于 2019-11-26 16:30:30
问题 Is there an easy way to list everything in a package from within R? For example, if I type foreach::: and hit tab twice, I can see everything that's there. How else can I get those names of objects? Note, ls("package:foreach", all.names=TRUE) does not show things like .foreachGlobals 回答1: ls("package:foreach", all.names=TRUE) only shows what's attached to the search path, which only includes the objects exported from the namespace. Use ls on the results of getNamespace instead: ls

Add objects to package namespace

风流意气都作罢 提交于 2019-11-26 15:26:19
问题 I'd like to push a function inside a package namespace so it can access internal objects of that package (let's use stats package as an example). I've tried using myfun <- function(x) print(x) env = loadNamespace("stats") assign("myfun", myfun , env) But it is locked. So I've tried to unlock my object unlockBinding("myfun", env) Since myfun doesn't exist yet, I can't unlock it. Any help ? 回答1: Along the line of @Hadley's solution, but using the environment of the namespace, how about: