I asked an AI to help write this week's TidyTuesday blog

By Andrew Robson

December 8, 2022

I asked an AI to help me with this weeks TidyTuesday. I supplied Copy.AI with all the details of this weeks dataset and asked it to give me some ideas. This week’s TidyTuesday comes from the Elevators data package. I gave the following information to the AI.

This data package contains a data set of the registered elevator devices in New York City provided by the Department of Buildings in response to a September 2015 FOIL request.

The package is available for use and the raw data files are available in the github repository: https://github.com/EmilHvitfeldt/elevators/tree/main/data-raw

License: The above data is free to use under the terms of the MIT license.

Please use the following citation if you do download the data: Hvitfeldt E (2022). elevators: Data Package Containing Information About Elevators in NYC. https://github.com/EmilHvitfeldt/elevators, https://emilhvitfeldt.github.io/elevators/.

Here are its recommendations:

  • Where Can You Find the Oldest Elevators in NYC?
  • The age and speed of elevators in NYC, how far they travel and what the most crowded is: a blog around data on New York City elevators.
  • (If you have time) An analysis of the data of one building and what the objective is would be a great help.

To be honest, these are pretty good - if not a little strange. ‘If you have time’ is a bold opening for a sales pitch. Let’s do our best to make the AI proud. To get going, let’s load the data in and get a few packages and variables defined, which will help us/me in future.

remotes::install_github("emilhvitfeldt/elevators")
library(elevators)
library(tidyverse)
library(lubridate)

theme_minimal_blog <-  theme( panel.background = element_rect(fill='#FAF9F0', color=NA),
                              plot.background = element_rect(fill='#FAF9F0', color=NA))

It also came up with a great title for the post.

🤖 📣 The Waiting Game - a blog around elevator data in new york city

One thing to mention about the data, the definition of an elevator is slightly wider than I thought - it also includes escalators. Time to follow the AI’s orders.

🤖 📣 Where can you find the oldest elevators in NYC?

Good question! The data includes an approval_date which I’m going to use as a proxy for age. I can return the top 5 oldest but it isn’t that interesting by itself.

elevators %>%
  mutate(age = trunc((approval_date %--% now()) / years(1))) %>%
  select(age, street_name, house_number, device_type) %>%
  arrange(desc(age)) %>%
  slice(1:5)
## # A tibble: 5 × 4
##     age street_name  house_number device_type       
##   <dbl> <chr>        <chr>        <chr>             
## 1    97 W 86 ST      147          Passenger Elevator
## 2    73 WATER STREET 1            Passenger Elevator
## 3    59 BROADWAY     1652         Freight           
## 4    59 E 66 ST      8            Freight           
## 5    56 80 AVE       258-15       Passenger Elevator

Instead, let’s get the distribution of the age by the borough - maybe adoption was earlier in Manhattan?

elevators %>%
  mutate(age = trunc((approval_date %--% now()) / years(1))) %>%
  select(approval_date, age, borough) %>%
  ggplot(aes(y = age, x = borough, fill = borough)) +
  geom_violin(draw_quantiles = 0.5) +
  theme_minimal(13)  +
  theme(legend.position="none") +
  theme_minimal_blog +
  labs(y = 'Age of Elevator',
       x = ' ') 

We can see that all the boroughs are fairly similar. Manhattan has some really old elevators. Lot of elevators were built around 10 years ago and then there was a slow spell - possibly due to 9/11? There are many different types of elevator in this dataset, let’s see if the pattern changes when we account for that.

elevators %>%
  mutate(age = trunc((approval_date %--% now()) / years(1))) %>%
  filter(device_type %in% c('Dumbwaiter', 'Escalator', 'Freight', 'Passenger Elevator', 'Handicap Lift')) %>%
  select(approval_date, age, borough, device_type) %>%
  ggplot(aes(y = age, x = borough, fill = borough)) +
  geom_violin(draw_quantiles = 0.5) +
  theme_minimal(13)  +
  theme(legend.position="none") +
  theme_minimal_blog +
  labs(y = 'Age of Elevator',
       x = ' ') +
  facet_wrap(~device_type, ncol = 1)

What’s next, robot?

🤖 📣 The age and speed of elevators in NYC, how far they travel and what the most crowded is: a blog around data on New York City elevators.

Okay, there’s a lot to unpack in that one. We’ve already covered age so let’s start with the speed and crowdedness. Crowdedness is a little beyond the scope of this dataset but we do have capacity in pounds. Speed is given in feet per minute.

elevators %>%
  ggplot() +
  geom_point(aes( y = speed_fpm, x = capacity_lbs, colour = device_type), alpha = 0.5, size = 4)  +
  theme_minimal(13)  +
  theme(legend.position="bottom") +
  theme_minimal_blog +
  labs(y = 'Capacity (lbs)',
       x = 'Speed (fpm)',
       colour = 'Device Type') 

Escalators are fast but can’t carry many people and lifts are slow but can carry a lot - looks like one lift manages to break the pattern and stands alone.

Now let’s look at how far they travel. Again, we don’t have quite what we need in the dataset, but we can clean up the floor the elevators go to and then use the floor as a proxy for distance.

elevators %>%
  mutate(floors = str_extract(floor_to, "\\d+"),
         floors = as.numeric(floors)) %>%
  filter(!is.na(floors), floors < 100, floors > 0) %>%
  ggplot(aes(y = floors, x = borough, fill = borough))  +
  geom_violin(draw_quantiles = 0.5) +
  theme_minimal(13)  +
  theme(legend.position="none") +
  theme_minimal_blog +
  labs(y = 'Floors Travelled',
       x = ' ') 

Manhattan has the tallest buildings - Staten island is fairly short, not really mind blowing. Next?

🤖 📣 (If you have time) An analysis of the data of one building and what the objective is would be a great help.

I’m not really sure what the AI is getting at this time, what the objective is would be a great help. However, we can still analyse the data of just one building, but which one? Let’s find the building with the most elevators.

elevators %>%
  mutate(address = paste(house_number, street_name, zip_code)) %>%
  distinct(address, elevators_per_building) %>% 
  arrange(desc(elevators_per_building)) %>%
  slice(1:10) %>%
  mutate(address = reorder(address, elevators_per_building)) %>%
  ggplot(aes(y = address, x = elevators_per_building, fill = address)) +
  geom_bar(stat = 'identity') +
  theme_minimal(13)  +
  theme(legend.position="none") +
  theme_minimal_blog +
  labs(y = 'Building Address',
       x = 'Elevators per Building') 

Googling the address top of this list, it turns out it’s the Macy’s building - I’ve been there! I’ve ridden the escalators. Let’s plot elevator map to see how they all work together.

elevators %>%
  filter(elevators_per_building == 64) %>% 
  select(device_number, device_type, floor_to, floor_from) %>%
  mutate(floor_to = as.numeric(str_extract(floor_to, "\\d+"))) %>%
  mutate(floor_from = as.numeric(str_extract(floor_from, "\\d+"))) %>% 
  mutate(floor_to = ifelse(is.na(floor_to), 0, floor_to)) %>% 
  mutate(floor_from = ifelse(is.na(floor_from), 0, floor_from)) %>%
  mutate(reorder(device_number, floor_from)) %>%
  select(device_number, floor_from, floor_to, device_type) %>%
  ggplot() +
  geom_segment(aes(y = device_number, 
                   yend= device_number, 
                   x = floor_from, 
                   xend = floor_to, 
                   group = device_number, 
                   colour = device_type),
               linewidth = 1) +
  geom_point(aes(y = device_number, x = floor_from), colour = '#2D4628', size = 3) +
  geom_point(aes(y = device_number, x = floor_to), colour = '#2D4628', size = 3) +
  theme_minimal(13)  +
  theme(legend.position="bottom") +
  theme_minimal_blog +
  scale_x_continuous(breaks=c(0,2,4,6,8,10)) +
  labs(colour = 'Device Type',
       x = 'Floor',
       y = 'Elevator ID')

This one is quite interesting! We can see how all the escalators connect together and how the elevators span the entire building. I remember riding these escalators when I was in New York, they’re wooden and grand and I’m so glad the AI told me to investigate them. Let’s get the AI to wrap this up for us.

🤖 📣

This was an interesting experiment, I would do this again. Artificial intelligence will change the world.

It really did suggest that.

Posted on:
December 8, 2022
Length:
6 minute read, 1204 words
See Also: