Fill Dataframe with Outputs of ZipRadius

For people coming here in the future, looks like ZipRadius was archived on CRAN and can be found here.

Now, for the solution - I would use lapply along with dplyr::bind_rows. Just make sure you tack on the original zip using dplyr::mutate inside the lapply function.

# Your original code, except with the edit to coerce zip to character
library(tidyverse)

library(ZipRadius)
zip <- c(43207, 43208, 21201) %>% 
    as.character # Since zipRadius requires zip codes to be characters, not numbers
rad <- zipRadius(zip[1],100)
rad <- expand_grid(zip[1],rad)
rad <- rad %>% 
    select(
        "zip[1]",
        zip,
        Distance
    ) %>% 
    rename(
        zips_within_100mi = zip, 
        original_zip = "zip[1]"
    )

# This is how I would do it
lapply(
    zip,
    function(z) {
        # Where z is an individual zip
        radius <- zipRadius(
            zipcode = z, radius = 100
        ) %>% 
            mutate(
                original_zip = z
            ) %>% 
            select(
                original_zip,
                'zips_within_100mi' = zip,
                'distance' = Distance
            )    
    }
) %>% 
    bind_rows()
#>   original_zip zips_within_100mi distance
#> 1        43207             25095    94.68
#> 2        43207             25106    88.33
#> 3        43207             25123    98.06
#> 4        43207             25187    95.57
#> 5        43207             25239    93.97
#> 6        43207             25241    98.66

Created on 2022-06-01 by the reprex package (v1.0.0)