Skip to content

Commit

Permalink
additional updates for media and raw
Browse files Browse the repository at this point in the history
  • Loading branch information
jbennettufl committed Sep 16, 2024
1 parent c51d325 commit cf7ea11
Showing 1 changed file with 36 additions and 63 deletions.
99 changes: 36 additions & 63 deletions vignettes/Fields.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,18 @@ To identify the raw, or verbatim, fields available with the Search API, you can

```{r eval=verify_record_fields}
record_fields <- idig_meta_fields(type = "records", subset = "raw")
rfall <- data.frame(matrix(ncol = 3, nrow = 0))
for(i in 1:length(record_fields)){
if(length(record_fields[[i]]) == 2){
rf <- data.frame(matrix(ncol = 3, nrow = 0))
rf[1, 1] <- names(record_fields[i])
rf[1, 2] <- (record_fields[[i]])$type
rf[1, 3] <- (record_fields[[i]])$fieldName
rfall <- data.frame(matrix(ncol = 2, nrow = 0))
colnames(rfall) <- c("Type", "FieldNameValue")
for(i in 1:length(record_fields)) {
rf <- data.frame(
Type = record_fields[[i]]$type,
FieldNameValue = record_fields[[i]]$fieldName,
stringsAsFactors = FALSE
)
rfall <- rbind(rfall, rf)
}else{
sub <- record_fields[[i]]
for(j in 1:length(sub)){
rf <- data.frame(matrix(ncol = 3, nrow = 0))
rf[1, 1] <- names(sub[j])
rf[1, 2] <- (sub[[j]])$type
rf[1, 3] <- (sub[[j]])$fieldName
rfall <- rbind(rfall, rf)
}
}
}
colnames(rfall) <- c("name", "type", "fieldName")
colnames(rfall) <- c("type", "fieldName")
nrow(rfall)
```

Expand Down Expand Up @@ -118,60 +109,42 @@ To identify the raw, or verbatim, fields available with the Media Record API, yo

```{r eval=verify_record_fields}
media_fields <- idig_meta_fields(type = "media", subset = "raw")
mfall <- data.frame(matrix(ncol = 3, nrow = 0))
for(i in 1:length(media_fields)){
if(length(media_fields[[i]]) == 2){
mf <- data.frame(matrix(ncol = 3, nrow = 0))
mf[1, 1] <- names(media_fields[i])
mf[1, 2] <- (media_fields[[i]])$type
mf[1, 3] <- (media_fields[[i]])$fieldName
mfall <- rbind(mfall, mf)
}else{
sub <- media_fields[[i]]
for(j in 1:length(sub)){
mf <- data.frame(matrix(ncol = 3, nrow = 0))
mf[1, 1] <- names(sub[j])
mf[1, 2] <- (sub[[j]])$type
mf[1, 3] <- (sub[[j]])$fieldName
mfall <- rbind(mfall, mf)
}
}
}
colnames(mfall) <- c("name", "type", "fieldName")
mfall <- data.frame(matrix(ncol = 2, nrow = 0))
colnames(mfall) <- c("Type", "FieldNameValue")
for(i in 1:length(media_fields)) {
mf <- data.frame(
Type = media_fields[[i]]$type,
FieldNameValue = media_fields[[i]]$fieldName,
stringsAsFactors = FALSE
)
mfall <- rbind(mfall, mf)
}
colnames(mfall) <- c("type", "fieldName")
nrow(mfall)
```

Like the Search API, the Media Record API has fields that have been indexed and potentially modified by iDigBio. To identify the indexed fields available with the Media Record API, you can run the following:
```{r eval=verify_record_fields}
media_fields_index <- idig_meta_fields(type = "media", subset = "indexed")
mfalli <- data.frame(matrix(ncol = 3, nrow = 0))
for(i in 1:length(media_fields_index)){
if(length(media_fields_index[[i]]) == 2){
mf <- data.frame(matrix(ncol = 3, nrow = 0))
mf[1, 1] <- names(media_fields_index[i])
mf[1, 2] <- (media_fields_index[[i]])$type
mf[1, 3] <- (media_fields_index[[i]])$fieldName
mfalli <- rbind(mfalli, mf)
}else{
sub <- media_fields_index[[i]]
for(j in 1:length(sub)){
mf <- data.frame(matrix(ncol = 3, nrow = 0))
mf[1, 1] <- names(sub[j])
mf[1, 2] <- (sub[[j]])$type
mf[1, 3] <- (sub[[j]])$fieldName
mfalli <- rbind(mfalli, mf)
}
}
}
colnames(mfalli) <- c("name", "type", "fieldName")
media_fields_indexed <- idig_meta_fields(type = "media", subset = "indexed")
mfalli <- data.frame(matrix(ncol = 2, nrow = 0))
colnames(mfalli) <- c("Type", "FieldNameValue")
for(i in 1:length(media_fields_indexed)) {
mf <- data.frame(
Type = media_fields_indexed[[i]]$type,
FieldNameValue = media_fields_indexed[[i]]$fieldName,
stringsAsFactors = FALSE
)
mfalli <- rbind(mfalli, mf)
}
colnames(mfalli) <- c("type", "fieldName")
nrow(mfalli)
```

Note, all index fields associated with the Media Record API are returned by default with the `idig_search_media()` function.
```{r eval=verify_record_fields}
mfalli$name
mfalli$fieldName
```


Expand Down

0 comments on commit cf7ea11

Please sign in to comment.