Reputation: 23
I want to find the time that is needed to drive from one point to another for up to 1000 routes using the mapdist function. My idea was to use 1000 times the function mapdist and store each calculation in a dataframe like this:
library(ggmap)
df1 <- mapdist("'S GRAVENHAGESTRAAT, HEIST-OP-DEN-BERG","Nationalestraat 111, Antwerpen",mode="driving")
df2 <- mapdist("'S GRAVENWEZELSTWG, WIJNEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df3 <- mapdist("'S HERENBAAN, BOOM","Nationalestraat 111, Antwerpen",mode="driving")
df4 <- mapdist("'S HERENBAAN, REET","Nationalestraat 111, Antwerpen",mode="driving")
df5 <- mapdist("'S HERENLEI, KONTICH","Nationalestraat 111, Antwerpen",mode="driving")
df6 <- mapdist("'S HERENSTRAAT, BORGERHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df7 <- mapdist("'S HERENWEG, ITEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df8 <- mapdist("'S HERTOGENDIJK, HOEVENEN","Nationalestraat 111, Antwerpen",mode="driving")
df9 <- mapdist("'S HERTOGENDIJK, STABROEK","Nationalestraat 111, Antwerpen",mode="driving")
df10 <- mapdist("'T HOOGSTE, BORNEM","Nationalestraat 111, Antwerpen",mode="driving")
df11 <- mapdist("'T KAPMES, BOOISCHOT","Nationalestraat 111, Antwerpen",mode="driving")
df12 <- mapdist("'T LEITJE, MECHELEN","Nationalestraat 111, Antwerpen",mode="driving")
df13 <- mapdist("'T PLEIN, MECHELEN","Nationalestraat 111, Antwerpen",mode="driving")
df14 <- mapdist("'T PLEINTJE, ONZE-LIEVE-VROUW-WAVER","Nationalestraat 111, Antwerpen",mode="driving")
df15 <- mapdist("'T ROETJE, WUUSTWEZEL","Nationalestraat 111, Antwerpen",mode="driving")
df16 <- mapdist("'T SERCLAESDREEF, WOMMELGEM","Nationalestraat 111, Antwerpen",mode="driving")
df17 <- mapdist("'T SERCLAESLEI, BRASSCHAAT","Nationalestraat 111, Antwerpen",mode="driving")
df18 <- mapdist("'T SWEEN, WOMMELGEM","Nationalestraat 111, Antwerpen",mode="driving")
df19 <- mapdist("'T VEER, MECHELEN","Nationalestraat 111, Antwerpen",mode="driving")
df20 <- mapdist("'T VLIETJE, MECHELEN","Nationalestraat 111, Antwerpen",mode="driving")
df21 <- mapdist("1 MEISTRAAT, TERHAGEN","Nationalestraat 111, Antwerpen",mode="driving")
df22 <- mapdist("11E GENIESTRAAT, BURCHT","Nationalestraat 111, Antwerpen",mode="driving")
df23 <- mapdist("17E LICHT VLIEGWEZE, BALEN","Nationalestraat 111, Antwerpen",mode="driving")
df24 <- mapdist("4-SEPTEMBERLAAN, WILLEBROEK","Nationalestraat 111, Antwerpen",mode="driving")
df25 <- mapdist("A BEVERNAGELEI, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df26 <- mapdist("A BEYLTJENSSTRAAT, HOVE","Nationalestraat 111, Antwerpen",mode="driving")
df27 <- mapdist("A BIJNSSTRAAT, BERCHEM","Nationalestraat 111, Antwerpen",mode="driving")
df28 <- mapdist("A BLOMMAERTSTRAAT, WUUSTWEZEL","Nationalestraat 111, Antwerpen",mode="driving")
df29 <- mapdist("A BOELSTRAAT, WUUSTWEZEL","Nationalestraat 111, Antwerpen",mode="driving")
df30 <- mapdist("A BORINSTRAAT, ZWIJNDRECHT","Nationalestraat 111, Antwerpen",mode="driving")
df31 <- mapdist("A BROUWERSSTRAAT, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df32 <- mapdist("A BROUWERSTRAAT, ANTWERPEN","Nationalestraat 111, Antwerpen",mode="driving")
df33 <- mapdist("A BUTSSTRAAT, ZOERSEL","Nationalestraat 111, Antwerpen",mode="driving")
df34 <- mapdist("A C SWINNESTRAAT, STABROEK","Nationalestraat 111, Antwerpen",mode="driving")
df35 <- mapdist("A CANNAERTSSTRAAT, WESTERLO","Nationalestraat 111, Antwerpen",mode="driving")
df36 <- mapdist("A CHANTRAINESTRAAT, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df37 <- mapdist("A CLAESSENSSTRAAT, HOVE","Nationalestraat 111, Antwerpen",mode="driving")
df38 <- mapdist("A COOLSLAAN, EDEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df39 <- mapdist("A. COOLSSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df40 <- mapdist("A DE BRUYNSTRAAT, ITEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df41 <- mapdist("A DE CLERCKSTRAAT, SINT-JOB-IN-'T-GOOR","Nationalestraat 111, Antwerpen",mode="driving")
df42 <- mapdist("A DE COCKSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df43 <- mapdist("A DE GERLACHESTRAAT, EDEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df44 <- mapdist("A DE GRAEVESTRAAT, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df45 <- mapdist("A DE LAETSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df46 <- mapdist("A DE LALAINGSTRAAT, HOOGSTRATEN","Nationalestraat 111, Antwerpen",mode="driving")
df47 <- mapdist("A DE PRETERLAAN, KALMTHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df48 <- mapdist("A DE SCHUTTERSTRAAT, EKEREN","Nationalestraat 111, Antwerpen",mode="driving")
df49 <- mapdist("A DE VOSSTRAAT, GEEL","Nationalestraat 111, Antwerpen",mode="driving")
df50 <- mapdist("A DE VOSSTRAAT, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df51 <- mapdist("A DESMEDTLAAN, SINT-LENAARTS","Nationalestraat 111, Antwerpen",mode="driving")
df52 <- mapdist("A DICKSCHENSTRAAT, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df53 <- mapdist("A DIERCKXLAAN, SCHILDE","Nationalestraat 111, Antwerpen",mode="driving")
df54 <- mapdist("A DIERCKXSTRAAT, BALEN","Nationalestraat 111, Antwerpen",mode="driving")
df55 <- mapdist("A DILSLEI, 'S GRAVENWEZEL","Nationalestraat 111, Antwerpen",mode="driving")
df56 <- mapdist("A DINEURLAAN, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df57 <- mapdist("A DURERSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df58 <- mapdist("A EINSTEINLAAN, HOBOKEN","Nationalestraat 111, Antwerpen",mode="driving")
df59 <- mapdist("A EN WILLEMLAAN, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df60 <- mapdist("A ENGELSSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df61 <- mapdist("A FARNESEPLEIN, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df62 <- mapdist("A FRANCKSTRAAT, BOECHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df63 <- mapdist("A GEENENLAAN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df64 <- mapdist("A GHIJSSTRAAT, VOSSELAAR","Nationalestraat 111, Antwerpen",mode="driving")
df65 <- mapdist("A GOEMAERELEI, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df66 <- mapdist("A GRISARSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df67 <- mapdist("A HANSLAAN, KONTICH","Nationalestraat 111, Antwerpen",mode="driving")
df68 <- mapdist("A HERMANSLAAN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df69 <- mapdist("A HEULENSSTRAAT, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df70 <- mapdist("A JEURISSENSTRAAT, EKEREN","Nationalestraat 111, Antwerpen",mode="driving")
df71 <- mapdist("A JONCKERSSTRAAT, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df72 <- mapdist("A KENNISPLEIN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df73 <- mapdist("A LOUISASTRAAT, KAPELLEN","Nationalestraat 111, Antwerpen",mode="driving")
df74 <- mapdist("A MARSTBOOMSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df75 <- mapdist("A MATTHYSLAAN, BORGERHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df76 <- mapdist("A MEGENSPLEIN, MOL","Nationalestraat 111, Antwerpen",mode="driving")
df77 <- mapdist("A MENYSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df78 <- mapdist("A MEULEMANSSTRAAT, MERKSEM","Nationalestraat 111, Antwerpen",mode="driving")
df79 <- mapdist("A MICHIELSSTRAAT, ANTWERPEN","Nationalestraat 111, Antwerpen",mode="driving")
df80 <- mapdist("A MORTELMANSSTRAAT, WOMMELGEM","Nationalestraat 111, Antwerpen",mode="driving")
df81 <- mapdist("A NAHONLAAN, ZWIJNDRECHT","Nationalestraat 111, Antwerpen",mode="driving")
df82 <- mapdist("A NAHONLEI, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df83 <- mapdist("A NOBELLAAN, HOBOKEN","Nationalestraat 111, Antwerpen",mode="driving")
df84 <- mapdist("A OLEFFESTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df85 <- mapdist("A OSTSTRAAT, BORGERHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df86 <- mapdist("A OSTSTRAAT, HOOGSTRATEN","Nationalestraat 111, Antwerpen",mode="driving")
df87 <- mapdist("A OSTSTRAAT, ZWIJNDRECHT","Nationalestraat 111, Antwerpen",mode="driving")
df88 <- mapdist("A PEETERSLEI, KALMTHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df89 <- mapdist("A PEETERSSTRAAT, OUD-TURNHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df90 <- mapdist("A PETENLEI, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df91 <- mapdist("A PREUD HOMMESTRAAT, GEEL","Nationalestraat 111, Antwerpen",mode="driving")
df92 <- mapdist("A QUETELETLAAN, EDEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df93 <- mapdist("A REUSENSPLEIN, BRASSCHAAT","Nationalestraat 111, Antwerpen",mode="driving")
df94 <- mapdist("A RODENBACHLAAN, KONTICH","Nationalestraat 111, Antwerpen",mode="driving")
df95 <- mapdist("A RODENBACHLAAN, LINT","Nationalestraat 111, Antwerpen",mode="driving")
df96 <- mapdist("A RODENBACHPLAATS, SCHELLE","Nationalestraat 111, Antwerpen",mode="driving")
df97 <- mapdist("A RODENBACHPLANTSOEN, TURNHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df98 <- mapdist("A RODENBACHSTRAAT, BORGERHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df99 <- mapdist("A RODENBACHSTRAAT, HOVE","Nationalestraat 111, Antwerpen",mode="driving")
df100 <- mapdist("A RODENBACHSTRAAT, NIEL","Nationalestraat 111, Antwerpen",mode="driving")
df101 <- mapdist("A RODENBACHSTRAAT, ZWIJNDRECHT","Nationalestraat 111, Antwerpen",mode="driving")
df102 <- mapdist("A RONCALLILAAN, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df103 <- mapdist("A RYDAMSLAAN, MOL","Nationalestraat 111, Antwerpen",mode="driving")
df104 <- mapdist("A SANDERSLEI, AARTSELAAR","Nationalestraat 111, Antwerpen",mode="driving")
df105 <- mapdist("A SCHEYVAERTSLAAN, EKEREN","Nationalestraat 111, Antwerpen",mode="driving")
df106 <- mapdist("A SCHNEIDERLAAN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df107 <- mapdist("A SEGERSLEI, MORTSEL","Nationalestraat 111, Antwerpen",mode="driving")
df108 <- mapdist("A SERVAISLEI, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df109 <- mapdist("A SMETSTRAAT, DESSEL","Nationalestraat 111, Antwerpen",mode="driving")
df110 <- mapdist("A SNIEDERSSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df111 <- mapdist("A SOHIESTRAAT, OUD-TURNHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df112 <- mapdist("A SPIETAELSLAAN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df113 <- mapdist("A STERCKSTRAAT, BERCHEM","Nationalestraat 111, Antwerpen",mode="driving")
df114 <- mapdist("A STERCKXSTRAAT, WESTERLO","Nationalestraat 111, Antwerpen",mode="driving")
df115 <- mapdist("A STOCKMANSLEI, MORTSEL","Nationalestraat 111, Antwerpen",mode="driving")
df116 <- mapdist("A TIRELIRENSTRAAT, ESSEN","Nationalestraat 111, Antwerpen",mode="driving")
df117 <- mapdist("A ULLENSLEI, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df118 <- mapdist("A VAN BRABANTSTRAAT, AARTSELAAR","Nationalestraat 111, Antwerpen",mode="driving")
df119 <- mapdist("A VAN CAUWELAERTLAAN, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df120 <- mapdist("A VAN DAELSTRAAT, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df121 <- mapdist("A VAN DE VELDELAAN, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df122 <- mapdist("A VAN DE WIELELEI, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df123 <- mapdist("A VAN DEN BOSSCHELN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df124 <- mapdist("A VAN DEN SANDELAAN, SCHILDE","Nationalestraat 111, Antwerpen",mode="driving")
df125 <- mapdist("A VAN DIJCKSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df126 <- mapdist("A VAN DIJCKSTRAAT, GROBBENDONK","Nationalestraat 111, Antwerpen",mode="driving")
df127 <- mapdist("A VAN DIJCKSTRAAT, SCHILDE","Nationalestraat 111, Antwerpen",mode="driving")
df128 <- mapdist("A VAN DIJCKSTRAAT, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df129 <- mapdist("A VAN DIJCKSTRAAT, TURNHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df130 <- mapdist("A VAN HOORNSTRAAT, MORTSEL","Nationalestraat 111, Antwerpen",mode="driving")
df131 <- mapdist("A VAN LANDEGHEMPLEIN, WILLEBROEK","Nationalestraat 111, Antwerpen",mode="driving")
df132 <- mapdist("A VAN LANDEGHEMSTR, WILLEBROEK","Nationalestraat 111, Antwerpen",mode="driving")
df133 <- mapdist("A VAN PUTLEI, BORSBEEK","Nationalestraat 111, Antwerpen",mode="driving")
df134 <- mapdist("A VAN PUTLEI, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df135 <- mapdist("A VAN ROEYENSTRAAT, ZWIJNDRECHT","Nationalestraat 111, Antwerpen",mode="driving")
df136 <- mapdist("A VAN SOLMSSTRAAT, TURNHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df137 <- mapdist("A VAN SOLMSTRAAT, BAARLE-HERTOG","Nationalestraat 111, Antwerpen",mode="driving")
df138 <- mapdist("A VANDERPOORTENLAAN, LIER","Nationalestraat 111, Antwerpen",mode="driving")
df139 <- mapdist("A VERDIJCKSTRAAT, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df140 <- mapdist("A VERHOEVENLAAN, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df141 <- mapdist("A VERHOEVENLAAN, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df142 <- mapdist("A VERHOEVENLAAN, ZANDHOVEN","Nationalestraat 111, Antwerpen",mode="driving")
df143 <- mapdist("A VERMEYLENLAAN, AARTSELAAR","Nationalestraat 111, Antwerpen",mode="driving")
df144 <- mapdist("A VERMEYLENLAAN, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df145 <- mapdist("A VERMEYLENSTRAAT, NIEL","Nationalestraat 111, Antwerpen",mode="driving")
df146 <- mapdist("A VERVLIETLAAN, HEMIKSEM","Nationalestraat 111, Antwerpen",mode="driving")
df147 <- mapdist("A VESALIUSLAAN, EDEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df148 <- mapdist("A VESALIUSLAAN, ZOERSEL","Nationalestraat 111, Antwerpen",mode="driving")
df149 <- mapdist("A VRANCXLAAN, DEURNE","Nationalestraat 111, Antwerpen",mode="driving")
df150 <- mapdist("A WELLENSSTRAAT, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df151 <- mapdist("A WENSSTRAAT, EKEREN","Nationalestraat 111, Antwerpen",mode="driving")
df152 <- mapdist("A WESTERLINCKSTRAAT, GEEL","Nationalestraat 111, Antwerpen",mode="driving")
df153 <- mapdist("A WILLAERTSTRAAT, EDEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df154 <- mapdist("A WOLFSSTRAAT, SCHOTEN","Nationalestraat 111, Antwerpen",mode="driving")
df155 <- mapdist("A YSSACKERSSTRAAT, ESSEN","Nationalestraat 111, Antwerpen",mode="driving")
df156 <- mapdist("A ZONDER GRENZENSTR, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df157 <- mapdist("A. STOCLETLAAN, DUFFEL","Nationalestraat 111, Antwerpen",mode="driving")
df158 <- mapdist("A. VEREECKESTRAAT, HEIST-OP-DEN-BERG","Nationalestraat 111, Antwerpen",mode="driving")
df159 <- mapdist("A.B.STRAAT, MECHELEN","Nationalestraat 111, Antwerpen",mode="driving")
df160 <- mapdist("AAKLAAN, TISSELT","Nationalestraat 111, Antwerpen",mode="driving")
df161 <- mapdist("AALBESLEI, WILRIJK","Nationalestraat 111, Antwerpen",mode="driving")
df162 <- mapdist("AALM CUYPERSLAAN, STABROEK","Nationalestraat 111, Antwerpen",mode="driving")
df163 <- mapdist("AALMOEZENIERSSTRAAT, ANTWERPEN","Nationalestraat 111, Antwerpen",mode="driving")
df164 <- mapdist("AAMBEELDSTRAAT, BEERSE","Nationalestraat 111, Antwerpen",mode="driving")
df165 <- mapdist("AAMBEELDSTRAAT, MECHELEN","Nationalestraat 111, Antwerpen",mode="driving")
df166 <- mapdist("AARDBEEMDEN, MOL","Nationalestraat 111, Antwerpen",mode="driving")
df167 <- mapdist("AARDBEZIENSTRAAT, MEERHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df168 <- mapdist("AARDBRUGGESTRAAT, NIJLEN","Nationalestraat 111, Antwerpen",mode="driving")
df169 <- mapdist("AARDEKENSWEG, OOSTMALLE","Nationalestraat 111, Antwerpen",mode="driving")
df170 <- mapdist("AARDESTRAAT, BONHEIDEN","Nationalestraat 111, Antwerpen",mode="driving")
df171 <- mapdist("AARDSEWEG, GEEL","Nationalestraat 111, Antwerpen",mode="driving")
df172 <- mapdist("AARDSTRAAT, KESSEL","Nationalestraat 111, Antwerpen",mode="driving")
df173 <- mapdist("AARDVELDEN, SINT-KATELIJNE-WAVER","Nationalestraat 111, Antwerpen",mode="driving")
df174 <- mapdist("AARLE, POPPEL","Nationalestraat 111, Antwerpen",mode="driving")
df175 <- mapdist("AARLEDIJK, POPPEL","Nationalestraat 111, Antwerpen",mode="driving")
df176 <- mapdist("AARSCHOTBAAN, BEERZEL","Nationalestraat 111, Antwerpen",mode="driving")
df177 <- mapdist("AARSCHOTSEBAAN, BERLAAR","Nationalestraat 111, Antwerpen",mode="driving")
df178 <- mapdist("AARSCHOTSEBAAN, HOUTVENNE","Nationalestraat 111, Antwerpen",mode="driving")
df179 <- mapdist("AARSCHOTSESTEENWEG, HERSELT","Nationalestraat 111, Antwerpen",mode="driving")
df180 <- mapdist("AARSCHOTSESTEENWEG, KONINGSHOOIKT","Nationalestraat 111, Antwerpen",mode="driving")
df181 <- mapdist("AARSCHOTSESTEENWEG, LIER","Nationalestraat 111, Antwerpen",mode="driving")
df182 <- mapdist("AARSCHOTSESTEENWEG, RAMSEL","Nationalestraat 111, Antwerpen",mode="driving")
df183 <- mapdist("AARSCHOTSEWEG, HERENTALS","Nationalestraat 111, Antwerpen",mode="driving")
df184 <- mapdist("AARSCHOTSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df185 <- mapdist("AARTHOF, TONGERLO","Nationalestraat 111, Antwerpen",mode="driving")
df186 <- mapdist("AARTRIJTSTRAAT, ARENDONK","Nationalestraat 111, Antwerpen",mode="driving")
df187 <- mapdist("AARTSELAARSTRAAT, EDEGEM","Nationalestraat 111, Antwerpen",mode="driving")
df188 <- mapdist("AARTSELAARSTRAAT, HOBOKEN","Nationalestraat 111, Antwerpen",mode="driving")
df189 <- mapdist("AASTRAAT, OUD-TURNHOUT","Nationalestraat 111, Antwerpen",mode="driving")
df190 <- mapdist("ABDIJLAAN, BRECHT","Nationalestraat 111, Antwerpen",mode="driving")
df191 <- mapdist("ABDIJLAAN, MOL","Nationalestraat 111, Antwerpen",mode="driving")
df192 <- mapdist("ABDIJLAAN, ZOERSEL","Nationalestraat 111, Antwerpen",mode="driving")
df193 <- mapdist("ABDIJSTRAAT, Antwerpen","Nationalestraat 111, Antwerpen",mode="driving")
df194 <- mapdist("ABDIJSTRAAT, BEERSE","Nationalestraat 111, Antwerpen",mode="driving")
df195 <- mapdist("ABDIJSTRAAT, HEMIKSEM","Nationalestraat 111, Antwerpen",mode="driving")
df196 <- mapdist("ABDIJSTRAAT, TONGERLO","Nationalestraat 111, Antwerpen",mode="driving")
df197 <- mapdist("ABDON BRAECKMANSSTR, RUMST","Nationalestraat 111, Antwerpen",mode="driving")
df198 <- mapdist("ABEEL, SINT-KATELIJNE-WAVER","Nationalestraat 111, Antwerpen",mode="driving")
df199 <- mapdist("ABEELSTRAAT, BOOISCHOT","Nationalestraat 111, Antwerpen",mode="driving")
Afterwards I would then merge these data frames into one single data frame and export it into a CSV file.
Nontheless, when I execute a chunk of requests, I receive several error messages that all look like this:
matching was not perfect, returning what was found. Error in
*tmp*
[[c(1, 1)]] : no such index at level 1
This message does not arrive at every request, but it seems to appear randomly at several requests.
Any suggestions on why this error may come up, and how this can be resolved?
Upvotes: 2
Views: 723
Reputation: 1360
as @Pascal mentioned your example code returns fine. Have you checked you are not going over the Google API limit. It currently stands at 2500 per day and has a limit per second as well, which I cant remember off hand at the moment.
Its roughly ~5 requests per second can be sent/received. Try breaking it into chunks and adding a delay.
EDIT
If you need to manually add a delay, use Sys.sleep(x)
, where x
is time in seconds.
Also a suggestion it may be a good idea to add to add all your dataframes into a single list, keeps your environment cleaner and easier to manage. You can then loop through the list creating the final dataframe.
dist_list <- list()
dist_list$df1 <- ggmap::...
dist_list$df2 <- ggmap::...
df <- do.call("rbind", dist_list)
EDIT 2
Although I just realised your df15
creates a 6 column df compared to the usual 8 due to missing km/miles etc. Therefore the do.call()
will fail.
Therefor you could use:
df <- dist_list[[1]]
for (i in 2:length(dist_list)) {
if (ncol(dist_list[[i]]) == ncol(df)){
df <- rbind(df, dist_list[[i]])
}
}
That will then create a df with all fully constructed directions.
BTW I never received any error in testing this. I will be due to API limits
Upvotes: 1