Skip to content

Commit

Permalink
add fields to grambank function; update autotype; fix and close #87
Browse files Browse the repository at this point in the history
  • Loading branch information
agricolamz committed May 28, 2023
1 parent b158f7c commit 1b5b611
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: lingtypology
Type: Package
Title: Linguistic Typology and Mapping
Version: 1.1.13
Version: 1.1.14
Depends: R (>= 3.5.0)
Imports:
leaflet,
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
lingtypology 1.1.14
- add `description` and `feature_name` fields to `grambank.feature()`
- update the `autotyp.feature()` function after the new release 1.1.1
- fix `stroke.color` #87, thanks to Maksim Melenchenko

lingtypology 1.1.13
- change `map.feature()` default palette using
- add `grambank.feature()`
Expand Down
2 changes: 1 addition & 1 deletion R/autotyp.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' AUTOTYP's Language identifiers
#'
#' Language identifiers from AUTOTYP v. 0.1.4 (\url{https://github.com/autotyp/autotyp-data/}). This dataset is created for \code{\link{autotyp.feature}} function.
#' Language identifiers from AUTOTYP v. 1.1.1 (\url{https://github.com/autotyp/autotyp-data/}). This dataset is created for \code{\link{autotyp.feature}} function.
#'
#' #' @format A data frame with 1342 rows and 3 variables:
#' \describe{
Expand Down
2 changes: 1 addition & 1 deletion R/autotyp.feature.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Bickel, Balthasar, Nichols, Johanna, Zakharko, Taras, Witzlack-Makarevich, Alena
Lowe, John B
},
doi = {10.5281/zenodo.6793367},
title = {The AUTOTYP database (v1.1.0)},
title = {The AUTOTYP database (v1.1.1)},
url = {https://doi.org/10.5281/zenodo.6793367},
year = {2022}
}")
Expand Down
17 changes: 12 additions & 5 deletions R/grambank.feature.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,25 +241,32 @@ eprint = {https://www.science.org/doi/pdf/10.1126/sciadv.adg6175}}
if (sum(!toupper(features) %in% features_set) < 1){
l <- utils::read.csv("https://raw.githubusercontent.com/grambank/grambank/master/cldf/languages.csv")
v <- utils::read.csv("https://raw.githubusercontent.com/grambank/grambank/master/cldf/values.csv")
c <- utils::read.csv("https://raw.githubusercontent.com/grambank/grambank/master/cldf/codes.csv")[,-1]
p <- utils::read.csv("https://raw.githubusercontent.com/grambank/grambank/master/cldf/parameters.csv")[,1:2]

merged_df <- merge(l, v, by.x = "ID", by.y = "Language_ID")
merged_df <- merge(merged_df, c, by.x = c("Parameter_ID", "Value"), by.y = c("Parameter_ID", "Name"))
merged_df <- merge(merged_df, p, by.x = c("Parameter_ID"), by.y = c("ID"))
merged_df <- merged_df[merged_df$Parameter_ID %in% toupper(features),
c("Name", "Glottocode", "Latitude", "Longitude",
"level", "Parameter_ID", "Value")]
c("Name.x", "Glottocode", "Latitude", "Longitude",
"level", "Parameter_ID", "Name.y", "Value", "Description")]

if(na.rm == TRUE){
merged_df$language <- lingtypology::lang.gltc(merged_df$Glottocode)
merged_df <- merged_df[!is.na(merged_df$language),]
colnames(merged_df) <- c("grambank.name", "glottocode", "latitude",
"longitude", "level", "feature_id", "value",
"longitude", "level", "feature_id", "feature_name", "value", "description",
"language")
} else {
colnames(merged_df) <- c("grambank.name", "glottocode", "latitude",
"longitude", "level", "feature_id", "value")
"longitude", "level", "feature_id", "feature_name", "value", "description")
}

datasets <- lapply(toupper(features), function(i){
df <- merged_df[merged_df$feature_id == i, -6]
colnames(df)[6] <- i
colnames(df)[7] <- i
colnames(df)[8] <- paste0("description_", i)
colnames(df)[6] <- paste0("feature_name_", i)
return(df)
})
final_df <- Reduce(merge, datasets)
Expand Down
2 changes: 1 addition & 1 deletion R/map.feature.R
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ map.feature <- function(languages,
stroke = FALSE,
radius = 1.15 * width,
fillOpacity = opacity,
color = rev.stroke.pal(mapfeat.stroke$stroke.features),
color = stroke.pal(mapfeat.stroke$stroke.features),
group = mapfeat.stroke$control)
}

Expand Down
Binary file modified data/autotyp.RData
Binary file not shown.
10 changes: 5 additions & 5 deletions database_creation/autotyp_database_creation.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ system("cd ~/Desktop/; git clone https://github.com/autotyp/autotyp-data")
files <- list.files("~/Desktop/autotyp-data/data/csv", recursive = TRUE)


file_variables %>%
distinct(file) %>%
pull(file) %>%
file_variables |>
distinct(file) |>
pull(file) |>
map_dfr(function(i){
data.frame(file = i,
path = str_subset(files, str_c(i, ".csv")))
}) %>%
full_join(file_variables) %>%
}) |>
full_join(file_variables) |>
filter(!(variable %in% c("LID", "Glottocode", "Language", "NPStructureExample", "Examples"))) ->
autotyp

Expand Down
2 changes: 1 addition & 1 deletion man/autotyp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b5b611

Please sign in to comment.