Type: | Package |
Title: | Visualize Downloads from 'CRAN' Packages |
Version: | 1.0.3 |
Date: | 2023-03-19 |
Author: | Marcelo Ponce [aut, cre] |
Maintainer: | Marcelo Ponce <m.ponce@utoronto.ca> |
Description: | Visualize the trends and historical downloads from packages in the 'CRAN' repository. Data is obtained by using the 'API' to query the database from the 'RStudio' 'CRAN' mirror. |
Imports: | graphics, stats, cranlogs, plotly, htmlwidgets |
Suggests: | knitr, devtools, roxygen2, testthat, rmarkdown |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://github.com/mponce0/Visualize.CRAN.Downloads |
BugReports: | https://github.com/mponce0/Visualize.CRAN.Downloads/issues |
RoxygenNote: | 7.1.0 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2023-03-19 15:33:58 UTC; marcelo |
Repository: | CRAN |
Date/Publication: | 2023-03-21 10:30:05 UTC |
function to check the existance of the directory and combine directory and file names
Description
function to check the existance of the directory and combine directory and file names
Usage
check.FileDir(dirSave = NULL, fileName)
Arguments
dirSave |
specify a valid directory where to save the file |
fileName |
name of the file |
Value
directory and filename combined, ie path to fileName
function to check dates, ie that t0<t1 and t0!=t1
Description
function to check dates, ie that t0<t1 and t0!=t1
Usage
checkDates(t0, t1)
Arguments
t0 |
initial date |
t1 |
final date |
Value
a list with t0 being [[1]] and t1 being [[2]]
function that generates a comparison plot among several packages
Description
function that generates a comparison plot among several packages
Usage
comparison.Plt(
pckgDwnlds.lst,
t0,
t1,
cmb = TRUE,
noMAvgs = FALSE,
noCBs = FALSE,
device = "PDF",
dirSave = NULL
)
Arguments
pckgDwnlds.lst |
nested list containing the several packages to process |
t0 |
initial date |
t1 |
final date |
cmb |
boolean flag, indicating whether the plots are shown in the same (default) graph or not |
noMAvgs |
boolean flag, indicating whether moving averages are displayed (default) or NOT –set to TRUE– |
noCBs |
boolean flag, indicating whether shaded confidence intervals are displayed (default) or NOT –set to TRUE– |
device |
string to select the output format: 'PDF'/'PNG'/'JPEG' or 'screen' |
dirSave |
specify a valid directory where to save the file |
function that generates interactive plots of the package downloads logs from CRAN
Description
function that generates interactive plots of the package downloads logs from CRAN
Usage
interactivePlots(
downloads.data,
mytitle = paste(downloads.data$package[1], "Package downloads counts"),
nbrPlts = 2,
month.ln = 30,
HTMLfile = paste0("Interactive_DWNLDS_", downloads.data$package[1], ".html"),
device = "HTML",
dirSave = NULL
)
Arguments
downloads.data |
total downloads from the package |
mytitle |
optional char argument specifying the title to be displayed |
nbrPlts |
optional numeric argument specifying number of plots to generate |
month.ln |
optional numeric argument specifying the lenght of the month in days |
HTMLfile |
an optional string argument specifying the name of the file where to save the plots |
device |
an optional string describing whether the interactive plot will be set to screen or to save in an HTLM file |
dirSave |
specify a valid directory where to save the plot |
Examples
## Not run:
packageXdownloads <- retrievePckgData("ggplot")[[1]]
interactivePlots(packageXdownloads)
## End(Not run)
function that returns the date from one year ago
Description
function that returns the date from one year ago
Usage
lastyear.date()
function to check and load an specific set of libraries
Description
function to check and load an specific set of libraries
Usage
loadLibrary(lib)
Arguments
lib |
is a list of packages to be loaded |
generic fn that computes the "fn" on a moving window
Description
generic fn that computes the "fn" on a moving window
Usage
movingFn(x, fn = mean, period = length(x), direction = "forward")
Arguments
x |
a numeric vector |
fn |
a function to be applied/computed, default is set to mean() |
period |
size of the "moving window", default set to the lenght of the vector |
direction |
type of moving avergage to consider: "forward", "centered", "backward"; ie. whether the window computation is ( "centered" / "forward" / "backward" ) wrt the data series |
Value
a vector with the 'moving operation' applied to the x vector
function to validate the type of file format and open the corresponding file
Description
function to validate the type of file format and open the corresponding file
Usage
outputType(
device,
dirSave = NULL,
fileName,
fileFmts,
combinePlts,
msg = "plot"
)
Arguments
device |
string to select the output format: 'PDF'/'PNG'/'JPEG' or 'screen' |
dirSave |
specify a valid directory where to save the file |
fileName |
name of the file |
fileFmts |
list with the acceptable format types, eg. c("PDF","PNG","JPEG") |
combinePlts |
boolean flag indicating whether plots are combined or not |
msg |
optional string to customiza message to the user |
main function to analyze a list of packages in a given time frame
Description
main function to analyze a list of packages in a given time frame
Usage
processPckg(
pckg.lst,
t0 = lastyear.date(),
t1 = today(),
opts = list(),
device = "PDF",
dirSave = NULL
)
Arguments
pckg.lst |
list of packages to process |
t0 |
initial date, begining of the time period given in "YYYY-MM-DD" format |
t1 |
final date, ending of the time period given in "YYYY-MM-DD" format |
opts |
a list of different options available for customizing the output |
device |
string to select the output format: 'PDF'/'PNG'/'JPEG' or 'screen' |
dirSave |
name of a valid directory where to save the file, eg. do not specify this argument or enter "." for using the current working directory |
Examples
# device is set to "screen" so no files are generated and plots will appear on "screen"
# alternative to 'device' are "PDF"/"PNG"/"JPEG"
processPckg("ehelp", device="screen")
processPckg(c("ehelp","plotly","ggplot2"), "2001-01-01", device="screen")
processPckg(c("ehelp","plotly","ggplot2"), "2001-01-01", opts="nostatic", device="screen")
processPckg(c("ehelp","plotly","ggplot2"), "2001-01-01",
opts=c("nostatic","nocombined","nointeractive"), device="screen")
function to download the data from the CRAN logs for an specific package
Description
function to download the data from the CRAN logs for an specific package
Usage
retrievePckgData(pckg = NULL, t0 = lastyear.date(), t1 = today())
Arguments
pckg |
is the name of the package to look for the downloads data |
t0 |
is the initial date |
t1 |
is the final date |
Value
a list composed of the stats from the original time frame and the last month
Examples
retrievePckgData("ehelp")
retrievePckgData("ehelp","2018-01-01","2020-01-01")
function that generates visual trends of the package downloads logs from CRAN, it will generate 4 plots: two histograms, a pulse plot and the main plot is a plot of the downloads as a function of time
Description
function that generates visual trends of the package downloads logs from CRAN, it will generate 4 plots: two histograms, a pulse plot and the main plot is a plot of the downloads as a function of time
Usage
staticPlots(
pckg.stats.total,
device = "PDF",
fileName = paste0("DWNLDS_", pckg.stats.total$package[1], ".", tolower(device)),
dirSave = NULL,
combinePlts = FALSE,
noMovAvg = FALSE,
noConfBands = FALSE,
cutOff.pts = 250,
dbg = FALSE
)
Arguments
pckg.stats.total |
total downloads from the package |
device |
string to select the output format: 'PDF'/'PNG'/'JPEG' or 'screen' |
fileName |
an optional string argument specifying the name of the file where to save the plots |
dirSave |
specify a valid directory where to save the plot |
combinePlts |
a boolean indicating whether the plots generated will be combined into one single figure or not |
noMovAvg |
a boolean indicating whether moving statistical estimators, such as, the moving average will be displayed |
noConfBands |
a boolean indicating whether a confidence band will be displayed |
cutOff.pts |
an integer value indicating the cut-off value to determine whether there would be a subsample for clarity sake in the plots |
dbg |
internal flag for activating debugging options, i.e. display furhter information in screen |
Examples
packageData <- retrievePckgData("ggplot2")
totalDownloads <- packageData[[1]]
#lastmonthDownloads <- packageData[[2]]
staticPlots(totalDownloads, device="screen")
staticPlots(totalDownloads,combinePlts=TRUE, device="screen")
function to display the summary of the data
Description
function to display the summary of the data
Usage
summaries(data1, deltaTs = 30)
Arguments
data1 |
first dataset, eg. total data |
deltaTs |
a numerical (integer) value, indicating the lenght –in days– for selecting a subset of the original dataset; default value is 1 mont, ie. 30 days |
Examples
packageXdownloads <- retrievePckgData("ehelp")[[1]]
summaries(packageXdownloads)
function to identify units of times and time intervals for customizing axes of plots
Description
function to identify units of times and time intervals for customizing axes of plots
Usage
## S3 method for class 'intervals'
time(tot.days)
Arguments
tot.days |
number of days in time interval to consider |
Value
a list with the unit of time and time interval
function to identify units of times based on the number of days
Description
function to identify units of times based on the number of days
Usage
## S3 method for class 'units'
time(tot.days)
Arguments
tot.days |
number of days |
Value
a vector with the "time units" included in the total number of days
function that returns the current date
Description
function that returns the current date
Usage
today()