Download product information and reviews from Amazon.com

Rmazon

The goal of Rmazon is to help you download product information and reviews from Amazon.com easily.

Installation

You can install Rmazon from github with:

# install.packages("devtools")
devtools::install_github("56north/Rmazon")

Example – product information

This is a basic example which shows you how ro get product information:

# Get product information for 'The Art of R Programming: A Tour of Statistical Software Design'

product_info <- Rmazon::get_product_info("1593273843")

Example – product reviews

This is a basic example which shows you how gto et reviews:

# Get reviews for 'The Art of R Programming: A Tour of Statistical Software Design'

reviews <- Rmazon::get_reviews("1593273843")

nutrients

Calculate your nutrients with my new package: NutrientData

I have created a new package: NutrientData

This package contains data sets with the composition of Foods: Raw, Processed, Prepared. The source of the data is the USDA National Nutrient Database for Standard Reference, Release 28 (2015), a long with two functions to search and calculate nutrients.

You download it from github:
devtools::install_github("56north/NutrientData")

Lets first have a look at the the top 20 calorie dense foods

library(NutrientData)
library(dplyr)

data("ABBREV") # Load the data

ABBREV %>% # Select the data
arrange(-Energ_Kcal) %>% # Sort by calories per 100 g
select(Food = Shrt_Desc, Calories = Energ_Kcal) %>% # Select relevant columns
slice(1:20) %>% # Choose the top 20

If you want to search for a specific ingredient you use the “search_ingredient” function. Lets search for raw onions:

search_ingredient("onion,raw")

You can also calculate the nutrient composition of several foods, like a simple yet delicious cabbage salad:

ingredients <- c("CABBAGE,RAW", "MAYONNAISE,RED FAT,W/ OLIVE OIL", "ONIONS,RAW")
grams <- c(100, 20, 10)

calculate_nutrients(ingredients, grams) %>%
select(Food = 1, Calories = 3, Protein = 4,
Fat = 5, Carbs = 7) %>% # Select only a few variables for looks and rename

Dinner is served. I look forward to your feedback! And if anyone is up for it, then this is a package that is just begging for cool visualizations for nutrient composition along with a Shiny overlay.!

hexdk

Create your own hexamaps

Hexamaps are gaining in popularity. Most notably has been the versions, where the map of the USA has been made into a hexamap. But people have also made maps of Europe using hexagons.

The idea is that one unit is one hexagon. So in case of the US, each state is one hexagon. In the case of Europe, each country is a hexagon.

This means that all units (states, countries, etc.) are the same size. This of course skews the hexamap in relation to the real geographic proportions. But it gives the advantage of giving all units equal size for displaying information – for instance a shade or color depending on some underlying values.

I have made a hexamap of the municipalities in Denmark. The capital region is very dense so I had to sort of map that on the side. You can see my efforts here:

hexdk

To ease the process I’ve made the hexamapmaker package. It takes a set of points and turns them into hexagons. That means that you can quickly and easily design and produce hexamaps.

Below I’ve included the example code from the package if you want to get started yourself. If you create a map of your own please share it with me on twitter @mikkelkrogsholm. I’d love to see your work!
# Install hexamapmaker
devtools::install_github(“56north/hexamapmaker”)
library(hexamapmaker)

# Create data frame
# Notice the spacing of the points

x <- c(1,3,2,4,1,3,7,8)
y <- c(1,1,3,3,5,5,1,3)
id <- c(“test1”, “test2”, “test3”, “test4”, “test5”, “test6”, “test7”, “test8″)
z <- data.frame(id,x,y)

# Plot points

library(ggplot2)
ggplot(z, aes(x, y, group = id)) +
geom_point() +
coord_fixed(ratio = 1) +
ylim(0,max(y)) + xlim(0,max(x))

# Turn points into hexagons

library(hexamapmaker)

zz <- hexamap(z)

ggplot(zz, aes(x, y, group = id)) +
geom_polygon(colour=”black”, fill = NA) +
coord_fixed(ratio = 1)

Kun ældre mænd vinder Nobelprisen i Økonomi

Det ser ud til at kun ældre mænd kan vinde Nobelprisen i økonomi, hvorimod selv helt unge kan vinde Nobelprisen i fysik. Forskellen kan ses i nedenstående graf, der viser alderspredningen i de forskellige nobelpriser. Det er bemærkelsesværdig at de naturvidenskabelige fag (fysik, kemi og medicin) har en langt større spredning end de samfundsfaglige og humanistiske (litteratur og økonomi).

Hvor er bogstaverne?

“Nogle visualiseringer viser ting du ikke vidste, og andre gange viser det ting du vidste, men ikke vidste du vidste.” – David Taylor, prooffreader.com


 

Det viser prooffreader.com’s interessante opgørelse over, hvor bogstaverne optræder i det engelske sprog. Det er nogle sjove figurer de har lavet som man kan nørde lidt over.

Klik videre til det oprindelige blogindlæg.

Kvinderne flygter til storbyerne

I år 2040 vil store dele af Nord- og Vestjylland være affolket for kvinder. De er nemlig flyttet til de større byer, viser en gennemgang af befolkningsfremskrivningen fra Danmarks Statistik. Nedenstående kort viser, hvordan, der i nogle af de Nord- og Vestjyske kommuner vil være mellem 10% – 30% flere mænd end kvinder. Det betyder kort fortalt en masse single mænd, der ikke kan finde en sød kæreste.

Det modsatte fænomen ser vi til gengæld i storbyerne, hvor der er langt flere kvinder end mænd. Især skiller et par Nordsjællandske kommuner sig ud – her er der rigtigt mange kvinder.

gendergap