Skip to content

Commit

Permalink
Make fieldsdf external data
Browse files Browse the repository at this point in the history
  • Loading branch information
crew102 committed Jun 5, 2017
1 parent 8b1c908 commit 7b86056
Show file tree
Hide file tree
Showing 6 changed files with 1,051 additions and 1,002 deletions.
19 changes: 19 additions & 0 deletions R/data.R
@@ -0,0 +1,19 @@
#' Fields data
#'
#' A data frame containing the names of retrievable fields for each of the 7
#' API endpoints. A yes/no flag (\code{can_query}) indicates which fields can
#' be included in the user's query.
#'
#' @format A data frame with 992 rows and 7 variables:
#' \describe{
#' \item{endpoint}{The endpoint that this field record is for}
#' \item{field}{The name of the field}
#' \item{data_type}{The field's data type (string, date, float, integer,
#' fulltext)}
#' \item{can_query}{An indicator for whether the field can be included in
#' the user query for the endpoint shown in \code{endpoint}}
#' \item{group}{The group the field belongs to}
#' \item{common_name}{The field's common name}
#' \item{description}{A description of the field}
#' }
"fieldsdf"
Binary file removed R/sysdata.rda
Binary file not shown.
21 changes: 12 additions & 9 deletions data-raw/fieldsdf.R
Expand Up @@ -17,9 +17,11 @@ clean_field <- function(x) gsub("[^[:alnum:]_]", "", tolower(as.character(x)))
fields <-
melt(all_tabs) %>%
rename(field = `API Field Name`, data_type = Type, can_query = Query,
endpoint = L1, group = Group) %>%
select(endpoint, field, data_type, can_query, group) %>%
mutate_each(funs(clean_field)) %>%
endpoint = L1, group = Group, common_name = `Common Name`,
description = Description) %>%
select(endpoint, field, data_type, can_query, group,
common_name, description) %>%
mutate_at(vars(1:5), funs(clean_field)) %>%
mutate(endpoint = case_when(
.$endpoint == "patent" ~ "patents",
.$endpoint == "inventor" ~ "inventors",
Expand All @@ -40,12 +42,13 @@ fieldsdf <-
data_type = rep("string", 7),
can_query = rep("y", 7),
group = rep("patents", 7),
common_name = rep("Patent ID", 7),
description = rep("Unique database ID for patent", 7),
stringsAsFactors = FALSE
) %>%
rbind(fields) %>%
arrange(endpoint, field) %>%
distinct()
) %>%
rbind(fields) %>%
arrange(endpoint, field) %>%
distinct()

write.csv(fieldsdf, "data-raw/fieldsdf.csv", row.names = FALSE)
# tools::checkRdaFiles("R/")
use_data(fieldsdf, internal = TRUE, overwrite = TRUE, compress = "gzip")
use_data(fieldsdf, internal = FALSE, overwrite = TRUE)

0 comments on commit 7b86056

Please sign in to comment.