r-package
Show names of everything in a package
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(getNamespace(“foreach”), all.names=TRUE)
How can I document data sets with roxygen?
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 … Read more
Creating a local R package repository
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, 2.9, … Read more
Can’t download data from Yahoo Finance using Quantmod in R
The price history csv URL’s appear to have changed Old https://chart.finance.yahoo.com/table.csv?s=AAPL&a=2&b=17&c=2017&d=3&e=17&f=2017&g=d&ignore=.csv New: https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1492438581&period2=1495030581&interval=1d&events=history&crumb=XXXXXXX The new version appends a “crumb” field which appears to reflect cookie information in the user’s browser. It seems they are intentionally blocking automated downloads of price histories and forcing queries to provide information to validate cookies in a web browser
Add objects to package namespace
Along the line of @Hadley’s solution, but using the environment of the namespace, how about: environment(myfun) <- asNamespace(‘stats’)
How to load packages in R automatically?
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 = character())’ will attach no … Read more