Learn R Programming

hexFinder

Scavenge the web for possible hex logos for CRAN packages.


installation

1 - Install the package:
# Most recent development version from github:
devtools::install_github('pedrocoutinhosilva/hexFinder')
2 - Include it in your project:
library(hexFinder)

Usage

Call the find_hex() function with the name of the package you would like to find a hex logo for, and optionally, a place where the logo will be stored:

> find_hex("ggplot2", "output")
Downloaded from GitHub repo hex for ggplot2
[1] "output/ggplot2.png"

When a package is not on CRAN, or a logo for the package cannot be found, a simple logo will be generated:

> find_hex("notapackage", "output")
Not a cran package
No logo found, generated hex for notapackage
[1] "output/notapackage.svg"

As an alternative, you can also use the scavenge() function. It is functionality the same as find_hex(), but with extra raccoons:

> scavenge("rlang", "output")
Summoning racoons to help with the search...
         /\ /\
       -'<o_o>'-   _
         () ()\  ,'_\
         ( . ) )/._./
         (_)-(_).--'
Downloaded from GitHub repo hex for rlang
[1] "output/rlang.png"

Dealing with github API limits

The Github API used by this package does have some limits. The first time in a session that you make a search you might see the following message:

> find_hex("devtools", "output")
No github personal access token provided.
Limited search rates for github will apply.
Set up github_pat global variable if you plan to query multiple repos in a short time
Downloaded from GitHub repo hex for devtools
[1] "output/devtools.svg"

This limit is normally not a problem (Its around 50 requests per hour), but if you are planning to do a large amount of searches, you can set up a github_pat global variable using a .Renviron file or calling Sys.setenv():

Sys.setenv(github_pat = "your_personal_access_token")

More information on how to get a github personal access token, at https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token.

Documentation

Online documentation is available at: https://www.anatomyofcode.com/hexFinder

Copy Link

Version

Install

install.packages('hexFinder')

Monthly Downloads

16

Version

0.8.2

License

MIT + file LICENSE

Maintainer

Pedro Silva

Last Published

January 17th, 2024

Functions in hexFinder (0.8.2)

log

Logs a given message.
check_known_repos

Searches a list of known package hex curated lists for a given package name
check_known_packages

Searches a list of known package hex links for a given package name
get_metacran_info

Returns metacran information about a given package
get_possible_paths

Search the given content for paths that match the constrains from ignore_patterns and logo_patterns.
url_file_exists

Checks if a given url is valid and available.
crop_image

Crops the empty space from a image
clean_repo_links

Returns gitub repo links based on given URLs
search_repo_logo

Searches a given github repo URL for the best hex logo image.
download_logo

Download a logo image
catch

Catches errors from a given expression. Can be used in a pipe.
locate_repo

Finds the best repo for a given package
scavenge

Same as [find_hex], but with extra raccoons
generate_hex

Generates a default logo for a package.
get_endpoint_content

Fetch the content of a endpoint. Multiple branches can be given, the content returned will also include which was the valid branch.
get_best_image

Returns the best image path from a list of image paths
get_cran_info

Returns CRAN information about a given package
find_hex

Finds hex logos for given packages
keep_good_ratio_images

Filters a list of image entries keeping images that might be a logo