cran.stats (version 0.1)

stats_logs: Calculate yearly, monthly or daily download stats

Description

Once the logs have been read in, this function can be used to calculate yearly, monthly or daily stats.

Usage

stats_logs(dt, type="monthly", pacakges="data.table", dependency=TRUE, duration=60L)

Arguments

dt
A data.table object with the download logs.
type
Calculates the number of downloads for specified packages monthly, daily or yearly. Default is monthly.
packages
A character vector of package names for which to calculate the stats for. Default is "data.table".
dependency
When TRUE (default), also computes stats for all packages that depend on this package and were downloaded within +/- seconds specified in duration in an attempt to get a better representation of the number of times just this package was downloaded.
duration
Default is 60 seconds. When dependency is TRUE, number of downloads for all packages that depend on this package and downloaded within +/- duration seconds are calculated and provided as an additional column.

Value

A data.table with the number of downloads for the specified time frame and type and an additional column indicating the number of downlaods most likely due to the packages that depend on it, if dependency is set to TRUE.

Details

By just looking at the number of downloads for each package provided in the packages argument, it'll not be possible to distinguish if the package was directly downloaded or was it because it was in the depends, suggests, imports etc. fields. In order to get the number of downloads for just the package that is specified, we start by gathering the number of downloads for all the packages that depend on it, within duration seconds +/-. We also use the proxy info provided for IP address from Rstudio mirror logs to find out if the dependent package and the actual package were downloaded by the same user. We add all the downloads for each package provided in the package argument which satisfy these criterion and provide this information as an additional column, in addition to the total number of downloads for the packages specified.

See Also

read_logs, plot_logs

Examples

## Not run: 
# dt = read_logs(dir="cran-mirror", verbose = TRUE)
# dt_s = stats_logs(dt)
# ## End(Not run)