Title: | Mine Metrics from Common Places on the Web |
---|---|
Description: | Mine metrics on common places on the web through the power of their APIs (application programming interfaces). It also helps make the data in a format that is easily used for a dashboard or other purposes. There is an associated dashboard template and tutorials that are underdevelopment that help you fully utilize 'metricminer'. |
Authors: | Candace Savonen [aut, cre], Howard Baek [aut] |
Maintainer: | Candace Savonen <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2025-04-01 20:31:39 UTC |
Source: | https://github.com/fhdsl/metricminer |
This is a function that sets up the app. It's generally called by another function
app_set_up(app_name = "google")
app_set_up(app_name = "google")
app_name |
app would you like to authorize? Supported apps are 'google' 'calendly' and 'github' |
This is a function to authorize metricminer to access calendly, github or google noninteractively from passing in a keys or tokens.
auth_from_secret( app_name, token, access_token, refresh_token, cache = FALSE, in_test = FALSE )
auth_from_secret( app_name, token, access_token, refresh_token, cache = FALSE, in_test = FALSE )
app_name |
Which app are you trying to authorize? 'google', 'calendly' or 'github'? |
token |
For calendly or github, pass in the API key or Personal Access Token that you have set up from going to https://github.com/settings/tokens/new or https://calendly.com/integrations/api_webhooks respectively. |
access_token |
For Google, access token can be obtained from running authorize interactively: token <-authorize(); token$credentials$access_token |
refresh_token |
For Google, refresh token can be obtained from running authorize interactively: token <-authorize(); token$credentials$refresh_token |
cache |
Should the credentials be cached? TRUE or FALSE? |
in_test |
If setting up auth in a test, set to TRUE so that way the authorization doesn't stick |
OAuth token saved to the environment so the package access the API data
## Not run: # Example for authorizing Calendly # You go to https://calendly.com/integrations/api_webhooks to get an api key auth_from_secret("calendly", token = "A_calendly_token_here") # Example for GitHub # You go to https://github.com/settings/tokens/new to get a # Personal Access Token auth_from_secret("github", token = "ghp_a_github_pat_here") # Example for authorizing for Google token <- authorize("google") auth_from_secret( app_name = "google", access_token = token$credentials$access_token, refresh_token = token$credentials$refresh_token ) ## End(Not run)
## Not run: # Example for authorizing Calendly # You go to https://calendly.com/integrations/api_webhooks to get an api key auth_from_secret("calendly", token = "A_calendly_token_here") # Example for GitHub # You go to https://github.com/settings/tokens/new to get a # Personal Access Token auth_from_secret("github", token = "ghp_a_github_pat_here") # Example for authorizing for Google token <- authorize("google") auth_from_secret( app_name = "google", access_token = token$credentials$access_token, refresh_token = token$credentials$refresh_token ) ## End(Not run)
This is a function to authorize the R package to access APIs interactively. To learn more about the privacy policy for metricminer [read here](https://www.metricminer.org/privacypolicy.html)
authorize(app_name = NULL, cache = FALSE, ...)
authorize(app_name = NULL, cache = FALSE, ...)
app_name |
app would you like to authorize? Supported apps are 'google' 'calendly' and 'github' |
cache |
Should the token be cached as an .httr-oauth file or API keys stored as global options? |
... |
Additional arguments to send to oauth2.0_token |
API token saved to the environment or the cache so it can be grabbed by functions
## Not run: authorize() authorize("github") authorize("google") authorize("calendly") ## End(Not run)
## Not run: authorize() authorize("github") authorize("google") authorize("calendly") ## End(Not run)
This is a function that handles Calendly GET requests
calendly_get(url, token = NULL, user = NULL, count = NULL, page_token = NULL)
calendly_get(url, token = NULL, user = NULL, count = NULL, page_token = NULL)
url |
The endpoint URL for this API request |
token |
You can provide the API key directly using this argument or this function will attempt to grab an API key that was stored using the 'authorize("calendly")' function |
user |
The user param for Calendly. Usually looks like "https://api.calendly.com/users/c208a750-9214-4c62-9ee6-a1a9507c7b43" |
count |
For paginated GETs, you can specify how many things you'd like returned |
page_token |
For a paginated GET, what page are we on? |
Calendly REST API response as a list
## Not run: authorize("calendly") token <- get_token(app_name = "calendly") result_list <- calendly_get( url = "https://api.calendly.com/users/me", token = token ) ## End(Not run)
## Not run: authorize("calendly") token <- get_token(app_name = "calendly") result_list <- calendly_get( url = "https://api.calendly.com/users/me", token = token ) ## End(Not run)
if testthat's tests have been run, this will look for the check to see if anything truly broke It will return a TRUE/FALSE for whether or not there were errors based on the check/testthat.Rout file produced.
check_check(report_warning = TRUE)
check_check(report_warning = TRUE)
report_warning |
Should the number include warnings in addition errors? Default is both will be reported but if you'd like to ignore warnings set this to FALSE. |
a how many errors/warnings were found
These functions are to clean metric and dimension data from Google Analytics 'get_ga_stats()' function.
clean_ga_metrics(metrics = NULL, type = NULL)
clean_ga_metrics(metrics = NULL, type = NULL)
metrics |
a metrics object from 'get_ga_stats()' function |
type |
If type == "pages" then treat the data frame for in the instance that the dimensions of the subpages were collected |
a data frame of cleaned metrics from Google Analytics
This is a function to get metrics for all the repositories underneath an organization
clean_repo_metrics(repo_name, repo_metric_list)
clean_repo_metrics(repo_name, repo_metric_list)
repo_name |
The repository name. So for 'https://github.com/fhdsl/metricminer', it would be 'metricminer' |
repo_metric_list |
a list containing the metrics |
Metrics for a repository on GitHub
Default Credentials path
default_creds_path(app_name)
default_creds_path(app_name)
app_name |
What app set up are you looking for? Supported apps are 'google' 'calendly' and 'github' Get file path to an default credentials RDS |
This is a function to delete cached creds and creds in the current environment that were set by metricminer
delete_creds(app_name = "all")
delete_creds(app_name = "all")
app_name |
which app would you like to delete the creds for? Default is to delete the creds for all. |
Cached credentials are deleted and report is given back
## Not run: delete_creds("google") ## End(Not run)
## Not run: delete_creds("google") ## End(Not run)
Default creds path
encrypt_creds_path(app_name)
encrypt_creds_path(app_name)
app_name |
What app set up are you looking for? Supported apps are 'google' 'calendly' and 'github' |
Default Credentials path Get file path to an default credentials RDS
example_data_folder()
example_data_folder()
Returns the file path to folder where the example data is stored
This is a function to get extract answers from a Google Form. It is used by the 'get_google_form()' function if dataformat = "dataframe"
extract_answers(form_info)
extract_answers(form_info)
form_info |
The return form_info list that is extracted in 'get_google_form()' |
This returns answers from a google form
This is a function to get the Calendly API user info
get_calendly_user(token = NULL)
get_calendly_user(token = NULL)
token |
You can provide the API key directly using this argument or this function will attempt to grab an API key that was stored using the 'authorize("calendly")' function |
Calendly API user info as a list
## Not run: authorize("calendly") get_calendly_user() ## End(Not run)
## Not run: authorize("calendly") get_calendly_user() ## End(Not run)
This is a function to retrieve a list of papers that cite your papers
get_citation_count(paper_cite_link)
get_citation_count(paper_cite_link)
paper_cite_link |
This is not a google citation page. 1. Go to: https://scholar.google.com/scholar 2. Search for the paper we are looking for the citation count. 3. Then click the Cited by ___ button below the title of the paper 4. Copy and paste this url and put it in this get_citation_count() function |
A list of the example datasets available in this package
## Not run: paper_cite_link <- "https://scholar.google.com/scholar?cites=6140457238337460780" papers_cited_df <- get_citation_count(paper_cite_link) ## End(Not run)
## Not run: paper_cite_link <- "https://scholar.google.com/scholar?cites=6140457238337460780" papers_cited_df <- get_citation_count(paper_cite_link) ## End(Not run)
Get the _config_automation.yml file to set up a metricminer repo
get_config_file(overwrite = FALSE)
get_config_file(overwrite = FALSE)
overwrite |
Should a _config_automation.yml file in the current directory be overwritten? Default is false. |
Copies a config_automation.yml file to your current working directory
This is a function to retrieve a list of the example datasets included with metricminer
get_example_data(dataset_name, envir = 1)
get_example_data(dataset_name, envir = 1)
dataset_name |
the name of the example dataset to be retrieved from the metricminer package. |
envir |
By default the example data is saved in the global environment but this parameter allows you to change that if desired. |
an object in the environment of the same example dataset name that was requested.
## Not run: # You can see the list of example datasets by running: list_example_data() # Then use the datasetes of your interest by calling it with this function get_example_data("gform_info") # Then if you check your global environment you will see "gform_info" included ls() ## End(Not run)
## Not run: # You can see the list of example datasets by running: list_example_data() # Then use the datasetes of your interest by calling it with this function get_example_data("gform_info") # Then if you check your global environment you will see "gform_info" included ls() ## End(Not run)
This is a function to get the Google Analytics accounts that this user has access to. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
get_ga_metadata(property_id, token = NULL)
get_ga_metadata(property_id, token = NULL)
property_id |
a GA property. Looks like '123456789' Can be obtained from running 'get_ga_properties()' |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
A list showing the metadata types available for the Google Analytics property. This can be used to craft an API request.
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) property_id <- gsub("properties/", "", properties_list$name[1]) property_metadata <- get_ga_metadata(property_id = property_id) ## End(Not run)
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) property_id <- gsub("properties/", "", properties_list$name[1]) property_metadata <- get_ga_metadata(property_id = property_id) ## End(Not run)
This retrieves all the property ids associated with a Google Analytics Account. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
get_ga_properties(account_id, token = NULL)
get_ga_properties(account_id, token = NULL)
account_id |
the account id of the properties you are trying to retrieve |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
All the property ids and information about them for a Google Analytics account.
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) ## End(Not run)
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) ## End(Not run)
This is a function to get the Google Analytics accounts that this user has access to. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
get_ga_property_info(property_id, token = NULL)
get_ga_property_info(property_id, token = NULL)
property_id |
the property id you want information about. |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
All the property ids and information about them for a Google Analytics account.
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) property_id <- gsub("properties\\/", "", properties_list$name[1]) property_info <- get_ga_property_info(property_id = property_id) ## End(Not run)
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) property_id <- gsub("properties\\/", "", properties_list$name[1]) property_info <- get_ga_property_info(property_id = property_id) ## End(Not run)
This is a function to get the Google Analytics accounts that this user has access to. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
get_ga_stats( property_id, start_date = "2015-08-14", token = NULL, body_params = NULL, end_date = NULL, stats_type = "metrics", dataformat = "dataframe" )
get_ga_stats( property_id, start_date = "2015-08-14", token = NULL, body_params = NULL, end_date = NULL, stats_type = "metrics", dataformat = "dataframe" )
property_id |
a GA property. Looks like '123456789' Can be obtained from running 'get_ga_properties()' |
start_date |
YYYY-MM-DD format of what metric you'd like to collect metrics from to start. Default is the earliest date Google Analytics were collected. |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
body_params |
The body parameters for the request |
end_date |
YYYY-MM-DD format of what metric you'd like to collect metrics from to end. Default is today. |
stats_type |
Do you want to retrieve metrics or dimensions? |
dataformat |
How would you like the data returned to you? Default is a "dataframe" but if you'd like to see the original API list result, put "raw". |
Metrics dimensions for a GA returned from the Google Analytics API. It can be returned as a curated data.frame or the raw version which is the API response as a list
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[2]) property_id <- gsub("properties/", "", properties_list$name[1]) metrics <- get_ga_stats(property_id, stats_type = "metrics") dimensions <- get_ga_stats(property_id, stats_type = "dimensions") pages <- get_ga_stats(property_id, stats_type = "pages") ## End(Not run)
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[2]) property_id <- gsub("properties/", "", properties_list$name[1]) metrics <- get_ga_stats(property_id, stats_type = "metrics") dimensions <- get_ga_stats(property_id, stats_type = "dimensions") pages <- get_ga_stats(property_id, stats_type = "pages") ## End(Not run)
This is a function to get the Google Analytics accounts that this user has access to. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
get_ga_user(token = NULL, request_type = "GET")
get_ga_user(token = NULL, request_type = "GET")
token |
credentials for access to Google using OAuth. 'authorize("google")' |
request_type |
Is this a GET or a POST? |
Information about what accounts Google Analytics credentials has access to
## Not run: authorize("google") get_ga_user() ## End(Not run)
## Not run: authorize("google") get_ga_user() ## End(Not run)
This is a function to get the GitHub user's info
get_github(token = NULL, url)
get_github(token = NULL, url)
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
url |
What is the URL endpoint we are attempting to grab here? |
Information regarding a Github account
This is a function to get the information about a repository
get_github_metrics( repo, token = NULL, count = 1e+05, data_format = "dataframe", github_stats = "all", time_course = FALSE )
get_github_metrics( repo, token = NULL, count = 1e+05, data_format = "dataframe", github_stats = "all", time_course = FALSE )
repo |
The repository name. So for 'https://github.com/fhdsl/metricminer', it would be 'fhdsl/metricminer' |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
count |
How many items would you like to receive? default is 100000 |
data_format |
Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". |
github_stats |
Which stats would you like to collect from the GitHub API? Argument should be a vector of the names of the stats to be collected. This differs whether time_course is TRUE/FALSE. If time_course = FALSE should be a vector that can include: "repo_activity", "stars", "forks", "contributors", "community" If time_course = TRUE should be a vector that can include: "clones" and "views". By default "all" will be collected. |
time_course |
Should the time course data be collected or only the summary metrics? |
Repository summary or time course metrics for a particular GitHub repository as a dataframe
## Not run: authorize("github") metrics <- get_github_metrics(repo = "fhdsl/metricminer") # If you only want some of the stats you can choose which ones with the # github_stats argument metrics <- get_github_metrics( repo = "fhdsl/metricminer", github_stats = c("repo_activity", "stars")) summary_metrics <- get_github_repo_summary(repo = "fhdsl/metricminer") timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") ## End(Not run)
## Not run: authorize("github") metrics <- get_github_metrics(repo = "fhdsl/metricminer") # If you only want some of the stats you can choose which ones with the # github_stats argument metrics <- get_github_metrics( repo = "fhdsl/metricminer", github_stats = c("repo_activity", "stars")) summary_metrics <- get_github_repo_summary(repo = "fhdsl/metricminer") timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") ## End(Not run)
This is a wrapper for get_github_metrics
that has
'time_course = FALSE' so that summary metrics are collected
This is a function to get the information about a repository
get_github_repo_summary( repo, token = NULL, count = 1e+05, data_format = "dataframe", github_stats = "all" )
get_github_repo_summary( repo, token = NULL, count = 1e+05, data_format = "dataframe", github_stats = "all" )
repo |
The repository name. So for 'https://github.com/fhdsl/metricminer', it would be 'fhdsl/metricminer' |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
count |
How many items would you like to receive? default is 100000 |
data_format |
Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". |
github_stats |
Which stats would you like to collect from the GitHub API? Argument should be a vector of the names of the stats to be collected. This differs whether time_course is TRUE/FALSE. If time_course = FALSE should be a vector that can include: "repo_activity", "stars", "forks", "contributors", "community" If time_course = TRUE should be a vector that can include: "clones" and "views". By default "all" will be collected. |
GitHub repository summary metrics
## Not run: authorize("github") summary_metrics <- get_github_repo_summary(repo = "fhdsl/metricminer") ## End(Not run)
## Not run: authorize("github") summary_metrics <- get_github_repo_summary(repo = "fhdsl/metricminer") ## End(Not run)
This is a wrapper for get_github_metrics
that
has 'time_course = TRUE' so that timecourse metrics are collected
This is a function to get the information about a repository
get_github_repo_timecourse( repo, token = NULL, count = 1e+05, data_format = "dataframe", github_stats = "all" )
get_github_repo_timecourse( repo, token = NULL, count = 1e+05, data_format = "dataframe", github_stats = "all" )
repo |
The repository name. So for 'https://github.com/fhdsl/metricminer', it would be 'fhdsl/metricminer' |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
count |
How many items would you like to receive? default is 100000 |
data_format |
Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". |
github_stats |
Which stats would you like to collect from the GitHub API? Argument should be a vector of the names of the stats to be collected. This differs whether time_course is TRUE/FALSE. If time_course = FALSE should be a vector that can include: "repo_activity", "stars", "forks", "contributors", "community" If time_course = TRUE should be a vector that can include: "clones" and "views". By default "all" will be collected. |
GitHub repository timecourse metrics for views and clones
## Not run: authorize("github") timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") ## End(Not run)
## Not run: authorize("github") timecourse_metrics <- get_github_repo_timecourse(repo = "fhdsl/metricminer") ## End(Not run)
This is a function to get the GitHub user's info
get_github_user(token = NULL)
get_github_user(token = NULL)
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
Information regarding a Github account
## Not run: authorize("github") get_github_user() ## End(Not run)
## Not run: authorize("github") get_github_user() ## End(Not run)
This is a function to get Google Form info and responses from the API. The scopes it uses are the 'See all your Google Forms forms.' and 'See all responses to your Google Forms forms.' If you don't check this box on the OAuth screen this function won't work.
get_google_form(form_id, token = NULL, dataformat = "dataframe")
get_google_form(form_id, token = NULL, dataformat = "dataframe")
form_id |
The form ID we need to get |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
dataformat |
What format would you like the data? Options are "raw" or "dataframe". "dataframe" is the default. |
This returns a list of the form info and responses to the google form. Default is to make this a list of nicely formatted dataframes.
## Not run: authorize("google") form_info <- get_google_form( "https://docs.google.com/forms/d/1Neyj7wwNpn8wC7NzQND8kQ30cnbbETSpT0lKhX7uaQY/edit" ) form_id <- "https://docs.google.com/forms/d/1Neyj7wwNpn8wC7NzQND8kQ30cnbbETSpT0lKhX7uaQY/edit" ### OR You can give it a direct form id form_info <- get_google_form("1Neyj7wwNpn8wC7NzQND8kQ30cnbbETSpT0lKhX7uaQY") ## End(Not run)
## Not run: authorize("google") form_info <- get_google_form( "https://docs.google.com/forms/d/1Neyj7wwNpn8wC7NzQND8kQ30cnbbETSpT0lKhX7uaQY/edit" ) form_id <- "https://docs.google.com/forms/d/1Neyj7wwNpn8wC7NzQND8kQ30cnbbETSpT0lKhX7uaQY/edit" ### OR You can give it a direct form id form_info <- get_google_form("1Neyj7wwNpn8wC7NzQND8kQ30cnbbETSpT0lKhX7uaQY") ## End(Not run)
This is a wrapper function for returning google form info and responses for multiple forms at once. The scopes it uses are the 'See all your Google Forms forms.' and 'See all responses to your Google Forms forms.' If you don't check this box on the OAuth screen this function won't work.
get_multiple_forms(form_ids = NULL, token = NULL, dataformat = "dataframe")
get_multiple_forms(form_ids = NULL, token = NULL, dataformat = "dataframe")
form_ids |
a vector of form ids you'd like to retrieve information for |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
dataformat |
What format would you like the data? Options are "raw" or "dataframe". "dataframe" is the default. |
This returns a list of API information for google forms
## Not run: authorize("google") form_list <- googledrive::drive_find( shared_drive = googledrive::as_id("0AJb5Zemj0AAkUk9PVA"), type = "form" ) multiple_forms <- get_multiple_forms(form_ids = form_list$id) ## End(Not run)
## Not run: authorize("google") form_list <- googledrive::drive_find( shared_drive = googledrive::as_id("0AJb5Zemj0AAkUk9PVA"), type = "form" ) multiple_forms <- get_multiple_forms(form_ids = form_list$id) ## End(Not run)
This is a function to gets metrics and dimensions for all properties associated with an account. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
get_multiple_ga_metrics( account_id = NULL, property_ids = NULL, token = NULL, start_date = "2015-08-14", end_date = NULL, dataformat = "dataframe", stats_type = c("metrics", "dimensions", "link_clicks") )
get_multiple_ga_metrics( account_id = NULL, property_ids = NULL, token = NULL, start_date = "2015-08-14", end_date = NULL, dataformat = "dataframe", stats_type = c("metrics", "dimensions", "link_clicks") )
account_id |
the account id that you'd like to retrieve stats for all properties associated with it. |
property_ids |
A vector of property ids you'd like to retrieve metrics for. |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
start_date |
YYYY-MM-DD format of what metric you'd like to collect metrics from to start. Default is the earliest date Google Analytics were collected. |
end_date |
YYYY-MM-DD format of what metric you'd like to collect metrics from to end. Default is today. |
dataformat |
How would you like the data returned to you? Default is a "dataframe" but if you'd like to see the original API list result, put "raw". |
stats_type |
Do you want to retrieve metrics or dimensions? List all you want to collect as a vector |
Either a list of dataframes where 'metrics', 'dimensions' and 'link clicks' are reported. But if 'format' is set to "raw" then the original raw API results will be returned
A list of metrics, dimensions, and link clicks for a for all properties underneath a Google Analytics account. It can be returned as a curated data.frame or the raw version which is the API response as a list
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) property_ids <- gsub("properties/", "", properties_list$name[1:2]) all_properties <- get_multiple_ga_metrics(account_id = accounts$id[1]) some_properties <- get_multiple_ga_metrics(property_ids = property_ids) ## End(Not run)
## Not run: authorize("google") accounts <- get_ga_user() properties_list <- get_ga_properties(account_id = accounts$id[1]) property_ids <- gsub("properties/", "", properties_list$name[1:2]) all_properties <- get_multiple_ga_metrics(account_id = accounts$id[1]) some_properties <- get_multiple_ga_metrics(property_ids = property_ids) ## End(Not run)
This is a function to get metrics for a list of repos. You can provide an owner and attempt retrieve all repositories from a particular organization, or you can provide a character vector of repositories.
get_multiple_repos_metrics( repo_names = NULL, token = NULL, data_format = "dataframe", time_course = FALSE, github_stats = "all" )
get_multiple_repos_metrics( repo_names = NULL, token = NULL, data_format = "dataframe", time_course = FALSE, github_stats = "all" )
repo_names |
a character vector of repositories you'd like to collect metrics from. |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
data_format |
Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". |
time_course |
Should the time course data be collected or only the summary metrics? |
github_stats |
Which stats would you like to collect from the GitHub API? Argument should be a vector of the names of the stats to be collected. This differs whether time_course is TRUE/FALSE. If time_course = FALSE should be a vector that can include: "repo_activity", "stars", "forks", "contributors", "community" If time_course = TRUE should be a vector that can include: "clones" and "views". By default "all" will be collected. |
A list of metrics for a list of repos in a dataframe format
## Not run: authorize("github") repo_names <- c("fhdsl/metricminer", "jhudsl/OTTR_Template") some_repos_metrics <- get_multiple_repos_metrics(repo_names = repo_names) stars_and_forks <- get_multiple_repos_metrics(repo_names = repo_names, github_stats = c("stars", "forks")) some_repos_metrics <- get_multiple_repos_metrics(repo_names = repo_names, time_course = TRUE) ## End(Not run)
## Not run: authorize("github") repo_names <- c("fhdsl/metricminer", "jhudsl/OTTR_Template") some_repos_metrics <- get_multiple_repos_metrics(repo_names = repo_names) stars_and_forks <- get_multiple_repos_metrics(repo_names = repo_names, github_stats = c("stars", "forks")) some_repos_metrics <- get_multiple_repos_metrics(repo_names = repo_names, time_course = TRUE) ## End(Not run)
This is a function to get the information about a repository
get_org_repo_list( owner, count = 1e+05, data_format = "dataframe", token = NULL )
get_org_repo_list( owner, count = 1e+05, data_format = "dataframe", token = NULL )
owner |
The owner of the repository. So for 'https://github.com/fhdsl/metricminer', it would be 'fhdsl' |
count |
The number of responses that should be returned. Default is 100000 |
data_format |
Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
a list of repositories that an organization has
## Not run: authorize("github") get_org_repo_list(owner = "fhdsl") ## End(Not run)
## Not run: authorize("github") get_org_repo_list(owner = "fhdsl") ## End(Not run)
This is a function to get metadata about a Google Form. It is used by the 'get_google_form()' function if dataformat = "dataframe".
get_question_metadata(form_info)
get_question_metadata(form_info)
form_info |
The return form_info list that is extracted in 'get_google_form()' |
This returns metadata from a google form
This is a function to get slido response output files. The slido files must be saved as googlesheets and cannot be xlsx. The scope it uses is the 'See, edit, create, and delete all your Google Sheets spreadsheets.' If you don't check this box on the OAuth screen this function won't work.
get_slido_files( drive_id, token = NULL, recursive = TRUE, keep_duplicates = FALSE )
get_slido_files( drive_id, token = NULL, recursive = TRUE, keep_duplicates = FALSE )
drive_id |
a URL or drive id that has the slido response output files you are looking to get (will recursively search for files by default). |
token |
credentials for access to Google using OAuth. 'authorize("google")' |
recursive |
Should slido files be looked for recursively in this folder? default is TRUE. |
keep_duplicates |
By default we won't keep duplicated files if a two files have the same name. But if you set this to true, duplicates will be returned. |
A list of the slido files and their content in a Googledrive location.
## Not run: drive_id <- "https://drive.google.com/drive/folders/0AJb5Zemj0AAkUk9PVA" drive_id <- "https://drive.google.com/drive/u/0/folders/1XWXHHyj32Uw_UyaUJrqp6S--hHnM0-7l" slido_data <- get_slido_files(drive_id) ## End(Not run)
## Not run: drive_id <- "https://drive.google.com/drive/folders/0AJb5Zemj0AAkUk9PVA" drive_id <- "https://drive.google.com/drive/u/0/folders/1XWXHHyj32Uw_UyaUJrqp6S--hHnM0-7l" slido_data <- get_slido_files(drive_id) ## End(Not run)
Get timestamp repository metrics
get_timestamp_repo_metrics(results, column)
get_timestamp_repo_metrics(results, column)
results |
An API result from GitHub typically the views or clones for a repo |
column |
name of the column being extracted. Typically "views" or "clones" |
Extracted timestamp metrics from the API response
This is a function to get the information about a repository
get_user_repo_list( owner, count = 1e+05, data_format = "dataframe", token = NULL )
get_user_repo_list( owner, count = 1e+05, data_format = "dataframe", token = NULL )
owner |
The owner of the repository. So for 'https://github.com/fhdsl/metricminer', it would be 'fhdsl' |
count |
The number of responses that should be returned. Default is 100000 |
data_format |
Default is to return a curated data frame. However if you'd like to see the raw information returned from GitHub set format to "raw". |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
a list of repositories that an organization has
## Not run: authorize("github") get_user_repo_list(owner = "metricminer") ## End(Not run)
## Not run: authorize("github") get_user_repo_list(owner = "metricminer") ## End(Not run)
This is a function to retrieve statistics for a Youtube channel
get_youtube_channel_stats(channel_id, token = NULL, dataformat = "dataframe")
get_youtube_channel_stats(channel_id, token = NULL, dataformat = "dataframe")
channel_id |
ID of the Youtube channel to retrieve stats from. |
token |
OAuth token from Google login. |
dataformat |
How would you like the data returned to you? Default is a "dataframe" but if you'd like to see the original API list result, put "raw". |
A data frame of the channel stats from a Youtube channel.
## Not run: authorize("google") youtube_channel_stats <- get_youtube_channel_stats("UCr73I9ZEPbn-3_1CBM57QgQ") ## End(Not run)
## Not run: authorize("google") youtube_channel_stats <- get_youtube_channel_stats("UCr73I9ZEPbn-3_1CBM57QgQ") ## End(Not run)
This is a function to get a statistics on a Youtube video
get_youtube_video_stats(video_id, token = NULL, dataformat = "dataframe")
get_youtube_video_stats(video_id, token = NULL, dataformat = "dataframe")
video_id |
ID of the Youtube video to retrieve stats from. |
token |
OAuth token from Google login. https://www.youtube.com/watch?v=YkYnni-WuaQor just the "YkYnni-WuaQor" part that comes after the 'v=' bit. |
dataformat |
How would you like the data returned to you? Default is a "dataframe" but if you'd like to see the original API list result, put "raw". |
A data frame of the Youtube video stats.
## Not run: authorize("google") youtube_video_stats <- get_youtube_video_stats("YkYnni-WuaQ") ## End(Not run)
## Not run: authorize("google") youtube_video_stats <- get_youtube_video_stats("YkYnni-WuaQ") ## End(Not run)
This is a function that wraps up gh calls for us
gh_repo_wrapper(api_call, owner, repo, token = NULL, count = 1e+05)
gh_repo_wrapper(api_call, owner, repo, token = NULL, count = 1e+05)
api_call |
an API call and endpoint. That has 'owner' and 'user'. |
owner |
The repository name. So for 'https://github.com/fhdsl/metricminer', it would be 'fhdsl' |
repo |
The repository name. So for 'https://github.com/fhdsl/metricminer', it would be 'metricminer' |
token |
You can provide the Personal Access Token key directly or this function will attempt to grab a PAT that was stored using the 'authorize("github")' function |
count |
How many items would you like to receive? default is 100000 |
Metrics for a repository on GitHub
Get file path to an key encryption RDS
key_encrypt_creds_path()
key_encrypt_creds_path()
This is a function to get a list of scheduled events from a Calendly user.
list_calendly_events(token = NULL, user, count = 100)
list_calendly_events(token = NULL, user, count = 100)
token |
You can provide the API key directly using this argument or this function will attempt to grab an API key that was stored using the 'authorize("calendly")' function |
user |
You need to retrieve the Calendly user's URI. You can do this by doing 'user <- get_calendly_user()' and 'user$resource$uri' |
count |
The number of responses that should be returned. Default is 20 or you can say "all" to retrieve all. |
Calendly REST API response as a list
## Not run: authorize("calendly") user <- get_calendly_user() list_calendly_events(user = user$resource$uri) ## End(Not run)
## Not run: authorize("calendly") user <- get_calendly_user() list_calendly_events(user = user$resource$uri) ## End(Not run)
This is a function to retrieve a list of the example datasets included with metricminer
list_example_data()
list_example_data()
A list of the example datasets available in this package
## Not run: list_example_data() # Now you could use any of these example datasets that are printed out get_example_data("calendly_events") ## End(Not run)
## Not run: list_example_data() # Now you could use any of these example datasets that are printed out get_example_data("calendly_events") ## End(Not run)
This is a function that handles requests from Google Analytics. The scope it uses is the ‘See and download your Google Analytics data' If you don’t this check this box on the OAuth screen this won't work.
request_ga(token, url, query = NULL, body_params = NULL, request_type)
request_ga(token, url, query = NULL, body_params = NULL, request_type)
token |
credentials for access to Google using OAuth. 'authorize("google")' |
url |
The endpoint URL for the request |
query |
A list to be passed to query |
body_params |
The body parameters for the request |
request_type |
Is this a GET or a POST? |
An API response in the form of a list
This is a function to get the Google Forms API requests. The scopes it uses are the 'See all your Google Forms forms.' and 'See all responses to your Google Forms forms.' If you don't check this box on the OAuth screen this function won't work.
request_google_forms( token, url, body_params = NULL, query_params = NULL, return_request = TRUE )
request_google_forms( token, url, body_params = NULL, query_params = NULL, return_request = TRUE )
token |
credentials for access to Google using OAuth. 'authorize("google")' |
url |
The endpoint URL for the request |
body_params |
The body parameters for the request |
query_params |
The body parameters for the request |
return_request |
Should a list of the request be returned as well? |
This function returns a list from a API response JSON file
This is a function to setup a folder structure for metricminer data to be saved to. It depends on and reads Scope used for this function is the 'See, edit, create, and delete only the specific Google Drive files you use with this app.'
setup_folders( config_file = file.path(rprojroot::find_root(rprojroot::has_dir(".git")), "_config_automation.yml"), token = NULL )
setup_folders( config_file = file.path(rprojroot::find_root(rprojroot::has_dir(".git")), "_config_automation.yml"), token = NULL )
config_file |
The file path to the _config_automation.yml file |
token |
OAuth token from Google login. |
The googlesheet URL where the data has been written
## Not run: authorize("google") setup_folders( config_file = "_config_automation.yml" ) ## End(Not run)
## Not run: authorize("google") setup_folders( config_file = "_config_automation.yml" ) ## End(Not run)
This is function stores endpoints and supported app names
supported_endpoints()
supported_endpoints()
Write playlist details from YouTube
write_playlist_details(playlist_id, token = NULL, outfile = NULL)
write_playlist_details(playlist_id, token = NULL, outfile = NULL)
playlist_id |
string, playlist ID on YouTube |
token |
OAuth token from Google login. |
outfile |
string, a filename to which to write results in the 'resources' folder |
writes a file containing the dataframe of cleaned results
## Not run: # Not run write_playlist_details( playlist_id = shorts_playlist_id, outfile = "youtube_shorts_data.tsv" ) write_playlist_details( playlist_id = "PL6aYJ_0zJ4uCABkMngSYjPo_3c-nUUmio", outfile = "youtube_shorts_data.tsv" ) ## End(Not run)
## Not run: # Not run write_playlist_details( playlist_id = shorts_playlist_id, outfile = "youtube_shorts_data.tsv" ) write_playlist_details( playlist_id = "PL6aYJ_0zJ4uCABkMngSYjPo_3c-nUUmio", outfile = "youtube_shorts_data.tsv" ) ## End(Not run)
This is a function to write metricminer data to a Googlesheet. Scope used for this function is the 'See, edit, create, and delete only the specific Google Drive files you use with this app.' When you get to the OAuth consent screen. If you do not check this box, this function won't work.
write_to_gsheet( input, token = NULL, gsheet = NULL, overwrite = FALSE, append_rows = FALSE, sheet = 1, new_sheet = FALSE, ... )
write_to_gsheet( input, token = NULL, gsheet = NULL, overwrite = FALSE, append_rows = FALSE, sheet = 1, new_sheet = FALSE, ... )
input |
input data to write to a googlesheet |
token |
OAuth token from Google login. |
gsheet |
Optionally a googlesheet to write to |
overwrite |
TRUE/FALSE overwrite if there is data at the destination |
append_rows |
TRUE/FALSE should the data be appended to the data? |
sheet |
Index or name of the worksheet you want to write to. Forwarded to googlesheets4::write_sheet or googlesheets4::append_sheet to indicate what sheet it should be written to. |
new_sheet |
default is FALSE. But if it is anything else will be used as the name for a new worksheet that will be made and written to. |
... |
these parameters are sent to googlesheets4::write_sheet. |
The googlesheet URL where the data has been written
## Not run: authorize("github") repo_list <- get_user_repo_list(owner = "metricminer") gsheet <- paste0( "https://docs.google.com/spreadsheets/d/", "166MV4_1pfATB3Hes2HbdZCpkMc8JTT3u3eJes6Wu7Rk/edit#gid=0" ) write_to_gsheet(repo_list) datasheet <- write_to_gsheet( gsheet = gsheet, input = repo_list, append_rows = TRUE, sheet = 1 ) datasheet <- write_to_gsheet( gsheet = gsheet, input = repo_list, new_sheet = "github_data" ) ## End(Not run)
## Not run: authorize("github") repo_list <- get_user_repo_list(owner = "metricminer") gsheet <- paste0( "https://docs.google.com/spreadsheets/d/", "166MV4_1pfATB3Hes2HbdZCpkMc8JTT3u3eJes6Wu7Rk/edit#gid=0" ) write_to_gsheet(repo_list) datasheet <- write_to_gsheet( gsheet = gsheet, input = repo_list, append_rows = TRUE, sheet = 1 ) datasheet <- write_to_gsheet( gsheet = gsheet, input = repo_list, new_sheet = "github_data" ) ## End(Not run)