Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mine PAS for terminal dates for hoards
# Download data from PAS search
library(jsonlite)
url <- 'https://finds.org.uk/database/search/results/q/hoard/broadperiod/ROMAN/format/json'
json <- fromJSON(url)
total <- json$meta$totalResults
results <- json$meta$resultsPerPage
pagination <- ceiling(total/results)
keeps <- c("id","old_findID","fromdate", "todate")
data <- json$results
data <- data[,(names(data) %in% keeps)]
for (i in seq(from=2, to=pagination, by=1)){
urlDownload <- paste(url, '/page/', i, sep='')
pagedJson <- fromJSON(urlDownload)
records <- pagedJson$results
records <- records[,(names(records) %in% keeps)]
data <-rbind(data,records)
}
# Count occurrences by todate
occurences <-table(unlist(data$todate))
t <- as.data.frame(occurences)
names(t) <- c('terminalDate', 'frequency')
write.csv(t, file='hoards.csv',row.names=FALSE, na="")
plot(frequency ~ terminalDate, t)
terminalDate frequency
-227 1
-137 1
-113 1
-112 1
-108 1
-100 1
-95 1
-90 1
-83 1
-82 1
-50 2
-48 2
-46 1
-42 1
-31 22
-27 8
-16 2
-6 1
9 2
14 7
37 19
42 2
43 1
50 9
54 6
60 3
68 2
69 4
70 4
73 1
75 1
78 2
79 8
80 2
81 1
83 1
96 4
98 5
99 1
100 14
102 2
111 8
113 1
117 29
120 1
122 1
125 2
128 4
134 2
137 3
138 29
144 4
145 1
147 1
149 2
150 15
152 1
153 1
154 1
156 1
158 1
159 1
160 1
161 40
162 1
163 2
164 1
165 1
169 6
171 1
172 5
173 1
175 17
176 7
177 1
179 2
180 12
183 2
184 2
187 1
190 1
191 29
192 23
195 1
196 2
197 1
198 1
199 5
200 49
201 1
202 2
210 4
211 8
212 2
215 4
217 4
220 3
222 3
224 1
235 9
236 1
238 1
239 1
240 1
243 1
246 1
247 2
249 4
250 7
251 1
253 1
258 1
259 1
260 20
261 1
265 2
266 1
267 1
268 51
269 25
270 47
271 54
273 8
274 78
275 30
276 1
279 1
282 8
285 55
286 3
290 1
293 17
294 2
295 1
296 31
298 1
299 1
300 29
305 7
307 2
308 4
310 5
312 3
313 7
314 5
315 5
316 1
317 7
318 17
319 1
320 2
322 2
323 3
324 27
325 3
326 2
328 2
329 1
330 7
331 1
333 2
334 1
335 43
337 6
340 20
341 26
347 2
348 35
350 17
351 1
352 1
353 12
354 6
355 3
356 40
360 5
361 46
363 6
364 5
365 5
367 14
375 39
378 132
383 12
387 3
388 13
392 4
394 1
395 21
400 53
401 1
402 104
405 1
406 3
408 10
409 2
410 60
423 3
450 2
490 1
600 1
650 1
700 1
1100 1
1400 1
1500 1
1700 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment