Code Smoothie

2018 Hass Avocado Prices

The data is from "Avocado Prices" on Kaggle, which came from the Hass Avocado Board, 2018.

The roundabout way this was made

On the sqlite3 command line:
.mode csv
.import avocado.csv avocado

select region, avg(AveragePrice) as price from avocado group by region ORDER BY price;

.output avoprocessed.csv 
In R:
library(ggmap)

data = read.csv("avoprocessed.csv", stringsAsFactors=FALSE)

for (i in 1:nrow(data)) {
    print(data[i, "region"])
    latlon = geocode(data[i, 1])
    data$lon[i] = as.numeric(latlon[1])
    data$lat[i] = as.numeric(latlon(2))
}

write.csv(data, "avoprocessed_2.csv", row.names = TRUE)
See also the source of this webpage.

Data files

avocados.csv avoprocessed.csv avoprocessed_2.csv
Thought I was getting ripped off in a potential avocado purchase. Created and last updated Dec. 29, 2019.