R packages useful for sports analytics

If you’re into R and analyzing sports data, you’ll want to save this CRAN task view:

This CRAN Task View contains a list of packages useful for sports analytics. Most of the packages are sport-specific and are grouped as such. However, we also include a General section for packages that provide ancillary functionality relevant to sports analytics (e.g., team-themed color palettes), and a Modeling section for packages useful for statistical modeling. Throughout the task view, and collected in the Related links section at the end, we have included a list of selected books and articles that use some of these packages in substantive ways. Our goal in compiling this list is to help researchers find the tools they need to complete their work in R.

Tags: , ,

Colors for All, R package

If you use color as a visual encoding, you should make sure every one can actually see the differences in your scale. The cols4All package from Martijn Tennekes can help by ranking and categorizing a wide set of color schemes.

Color palettes are well organized and made consistent with each other. Moreover, they are scored on several aspects: color-blind-friendliness, the presence of intense colors (which should be avoided), the overall aesthetic harmony, and how many different hues are used. Finally, for each color palette a color for missing values is assigned, which is especially important for spatial data visualization. Currently we support three types: categorical (qualitative) palettes, sequential palettes, and diverging palettes. In the near future, more palette types will be added, such as cyclic, bivariate, and hierarchical.

Tags: , , ,

Spike maps in R

Spike maps use the height of spikes to encode data geographically. The format provides a similar effect to frequency trails where the layering looks 3-D-ish, except spikes are typically centered on an area instead of running parallel.

Anyways, like most visualization methods with a name, there is an R package for spike maps by Timothée Giraud.

If D3.js is your jam, there’s also a solution for that. You can also take the no-code route with Datawrapper.

Tags: ,

Posted by in Coding, package, R

Tags: ,

Permalink

Beware of Snail Mail: 10 Signs of a Suspicious Package

Cardboard boxes on a conveyor belt in a warehouse.

If you are anything like me, you love getting mail. There is something about opening the mailbox to find a postcard from a loved one or a care-package with homemade cookies that can make your day.

But not all packages are filled with love. Sometimes people send items and materials through the mail that are dangerous. These suspicious packages could contain a bomb, biological, chemical, or radiological threats. You could come into contact with a suspicious package at home, at work, or when you are out in public.

It is important for you to prepare and know how to identify a suspicious package and what you can do to stay safe.Suspicious Package Thumbnail

  1. Look at the handwriting. Suspicious packages are often addressed by hand in all capital letters, or with cut-and-paste lettering.
  2. Pay attention to the return address. Suspicious packages often do not have a return address, or they may be postmarked from a city that does not match the return address.
  3. Note the postage. A package with excessive postage (more than was necessary for a package to reach its destination) should be treated as suspicious. Sometimes suspicious packages are delivered with no postage.
  4. Wrapping matters. If a package is unprofessionally wrapped with excessive packing material such as tape and/or string it should be treated as suspicious. It may also be labeled with restrictive endorsements – Fragile: Handle with Care, Rush: Do Note Delay, Personal, Confidential, or Do Not X-Ray.
  5. Use your senses. Be aware if the package has an unknown liquid or powder seeping through the wrapping or a strange odor. Do NOT sniff, taste, or touch the package or ask others to do the same.
  6. Hands off. Do not open the item or shake or empty the contents.
  7. Keep your distance. If you think you are dealing with a suspicious package, leave the room and close the door behind you. It is important to section off or isolate the package so other people do not enter the area.
  8. Don’t run away.  Leaving the area could potentially spread dangerous or deadly materials to other locations, including your home.  The authorities will determine if you need to undergo decontamination, medical treatment, or simply monitoring for any side-effects.
  9. Call 9-1-1. Use a land line to call 9-1-1. Do not use a cell phone or device that sends a signal because it could trigger an explosive device.
  10. Stay calm. Listen to your intuition and do not worry about embarrassment if you are wrong about a package being suspicious. It is always better to be safe than sorry.

References

Interpolate your data for animation in R

The tweenr package in R, by Thomas Lin Pedersen, helps you interpolate data for easier animated transitions.

tweenr is a small package that makes it easy to interpolate your data between different states, specifying the length of each change, the easing of the transition and how many intermediary steps should be generated. tweenr works particularly well with gganimate but can be used for any case where interpolation of data is needed.

Why I’m just now learning about this, I have no clue. I thought we were friends.

Tags: , ,

Large-ish data packages in R

If you've played around with R enough, there comes a time when you just need some data to mess around with. Maybe it's to learn a new method or to make one of your own. R offers some small-ish, clean datasets to poke at, but sometimes you need bigger, messier data. Hadley Wickham from RStudio released four popular large-ish datasets in package form to help you with that.

I've released four new data packages to CRAN: babynames, fueleconomy, nasaweather and nycflights13. The goal of these packages is to provide some interesting, and relatively large, datasets to demonstrate various data analysis challenges in R. The package source code (on github, linked above) is fully reproducible so that you can see some data tidying in action, or make your own modifications to the data.

Good.

Create a barebones R package from scratch

While we're on an R kick, Hilary Parker described how to create an R package from scratch, not just to share code with others but to save yourself some time on future projects. It's not as hard as it seems.

This tutorial is not about making a beautiful, perfect R package. This tutorial is about creating a bare-minimum R package so that you don’t have to keep thinking to yourself, "I really should just make an R package with these functions so I don't have to keep copy/pasting them like a goddamn luddite." Seriously, it doesn't have to be about sharing your code (although that is an added benefit!). It is about saving yourself time. (n.b. this is my attitude about all reproducibility.)

I need to do this. I've been meaning to wrap everything up for a while now, but it seemed like such a chore. Sometimes I even go back to my own tutorials for copy and paste action. Now I know better. And that's half the battle.