I have a dataframe with two columns, zip and CSZip. I am trying to apply a function to each row using:
dist <- apply(vf, 1, zip_distance(zip, CSZip, lonlat = TRUE, units = "meters"))
But I get this error:
Error in as.character(zipcode_a) :
cannot coerce type 'closure' to vector of type 'character'
zip_distance is from the ZipCodeR package.
This is what 5 rows of vf looks like:
| zip | CSZip |
|---|---|
| 91723 | 90048 |
| 90814 | 90048 |
| 91604 | 90048 |
| 90805 | 90048 |
| 90255 | 90048 |
The ZipcodeR is has some funky behavior. Sometimes it is just easier to use a for loop: