Skip to content

Commit

Permalink
Foreign to nonlocal in data and code
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahpeoples committed Mar 22, 2021
1 parent 42a9bb2 commit c947466
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 163 deletions.
12 changes: 6 additions & 6 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @description The package applies filters from the Leisterer-Peoples et
#' al. (submitted) publication. The \code{game_filter} filters the games in
#' several optional steps. Filters include: (non-)games, ABVD codes, goal
#' structure coding, foreign games, matching the game ABVDs with ABVDs from
#' structure coding, introduced games, matching the game ABVDs with ABVDs from
#' Pulotu, matching the time frames of games to those from the
#' open-access Pulotu dataset on figshare (version: 2015) with either 0 or
#' 50 years added, and matching the ABVDs from the games with those from the
Expand Down Expand Up @@ -100,13 +100,13 @@ NULL
#' \item{\code{Goal_uncertainty}}{Uncertainty in the goal structure coding
#' (1 = uncertainty)}
#' \item{\code{Goal_comments}}{Comments regarding the goal structure coding}
#' \item{\code{Foreign_keywords}}{Indicates which keywords were found in the
#' \item{\code{Introduced_keywords}}{Indicates which keywords were found in the
#' game description(s)}
#' \item{\code{Foreign_coding}}{Whether the game description(s) indicate
#' foreign origin (foreign, not foreign, undetermined)}
#' \item{\code{Foreign_uncertainty}}{Uncertainty in the foreign coding
#' \item{\code{Introduced_coding}}{Whether the game description(s) indicate
#' non-local origin (non-local, local, undetermined)}
#' \item{\code{Introduced_uncertainty}}{Uncertainty in the introduced coding
#' (1 = uncertainty)}
#' \item{\code{Foreign_comments}}{Comments regarding the foreign coding}
#' \item{\code{Introduced_comments}}{Comments regarding the introduced coding}
#' \item{\code{Pulotu_time_ok_0}}{Indicates whether the "traditional" time
#' frame from Pulotu matches the time frame(s) from the game
#' (1 = same time frame, 0 = different time frames)}
Expand Down
35 changes: 18 additions & 17 deletions R/game_filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#' games with an ABVD code.
#' @param clean_GS logical, default set to FALSE. If TRUE, only include games
#' with a goal structure code.
#' @param clean_foreign several options. \code{remove_foreign} removes only
#' the games that were coded foreign. \code{only_foreign} removes all games
#' except those coded as foreign. \code{coded_nonforeign} removes all games
#' except those that were coded as not being foreign. \code{keep_all} keeps
#' all of the games without any foreign filter.
#' @param clean_origin several options. \code{remove_nonlocal} removes only
#' the games that were coded non-local, but keeps those that were undetermined
#' or NA. \code{only_nonlocal} removes all games except those coded as
#' introduced \code{only_local} removes all games except those that were
#' coded as local. \code{keep_all} keeps all of the games without any
#' origin filter.
#' @param clean_pulotu logical, default set to FALSE. If TRUE, includes games
#' with an ABVD code that matches ABVD codes from Pulotu (Pulotu version:
#' 2015).
Expand All @@ -31,15 +32,15 @@
#' Taxonomy.
#' @seealso \url{https://github.com/ccp-eva/AustronesianGames}
#' @examples
#' game_filter(Games, clean_games = TRUE, clean_foreign = "keep_all")
#' game_filter(Games, clean_games = TRUE, clean_foreign = "remove_foreign",
#' game_filter(Games, clean_games = TRUE, clean_origin = "keep_all")
#' game_filter(Games, clean_games = TRUE, clean_origin = "remove_nonlocal",
#' clean_pulotu = TRUE,
#' clean_pulotu_time_50 = TRUE)
#' game_filter(Games, clean_games = TRUE, clean_foreign = "only_foreign",
#' game_filter(Games, clean_games = TRUE, clean_origin = "only_nonlocal",
#' clean_pulotu = TRUE,
#' clean_pulotu_time_0 = TRUE)

game_filter <- function( ... , clean_games = FALSE , clean_ABVD = FALSE , clean_GS = FALSE , clean_foreign = "keep_all" , clean_pulotu = FALSE , clean_pulotu_time_0 = FALSE , clean_pulotu_time_50 = FALSE , clean_phylo = FALSE ){
game_filter <- function( ... , clean_games = FALSE , clean_ABVD = FALSE , clean_GS = FALSE , clean_origin = "keep_all" , clean_pulotu = FALSE , clean_pulotu_time_0 = FALSE , clean_pulotu_time_50 = FALSE , clean_phylo = FALSE ){

if( clean_games == TRUE ){
Games <- Games[ which( Games$Game == "1" ), ]
Expand All @@ -50,17 +51,17 @@ game_filter <- function( ... , clean_games = FALSE , clean_ABVD = FALSE , clean_
if( clean_GS == TRUE ){
Games <- Games[ which( !is.na( Games$Goal_structure )), ]
}
if( clean_foreign == "remove_foreign" ){
Games <- Games[ which( Games$Foreign_coding == "not_foreign" | Games$Foreign_coding == "undetermined" | is.na( Games$Foreign_coding )), ]
if( clean_origin == "remove_nonlocal" ){
Games <- Games[ which( Games$Introduced_coding == "local" | Games$Introduced_coding == "undetermined" | is.na( Games$Introduced_coding )), ]
}
if( clean_foreign == "only_foreign" ){
Games <- Games[ which( Games$Foreign_coding == "foreign" ), ]
if( clean_origin == "only_nonlocal" ){
Games <- Games[ which( Games$Introduced_coding == "nonlocal" ), ]
}
if( clean_foreign == "coded_nonforeign" ){
Games <- Games[ which( Games$Foreign_coding == "not_foreign" ), ]
if( clean_origin == "only_local" ){
Games <- Games[ which( Games$Introduced_coding == "local" ), ]
}
if( clean_foreign == "keep_all" ){
paste0( "keep all: no foreign filter applied" )
if( clean_origin == "keep_all" ){
paste0( "keep all: no origin filter applied" )
}
if( clean_pulotu == TRUE ){
Games <- Games[ which( Games$Game_ID %in% unlist( strsplit( Cultures$Game_ID[ which( !is.na( Cultures$Pulotu_culture ))], ";" ))),]
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ To use the game filter and access the game data, you need to install the `devtoo
```r
install.packages("devtools")
```
or from the development version on GitHub
```r
devtools::install_github("r-lib/devtools")
```

Then you can install the AustroGames package:
```r
Expand All @@ -30,21 +26,31 @@ data(Descriptions)
data(Cultures)
data(Sources)
```
The data can be viewed:
The data can be examined further:
```r
str(Games)
str(Descriptions)
str(Cultures)
str(Sources)
head(Games)
dim(Games)
colnames(Games)
```

To apply filters to the data, use `game_filter`.

In the following example of `game_filter`, we select the rows that were coded as being a rule-based game (i.e., no simple play), games that were coded as having a foreign origin (i.e., introduced into the cultural group), and games from ethnolinguistic groups that correspond to the Austronesian language phylogeny from Gray et al. (2009).
In the following example of `game_filter`, we select the rows that were coded as being a rule-based game (i.e., no simple play), games that were coded as having a non-local origin (i.e., introduced into the cultural group), and games from ethnolinguistic groups that correspond to the Austronesian language phylogeny from Gray et al. (2009).
```r
d <- game_filter(Games, clean_games = TRUE, clean_foreign = "only_foreign", clean_phylo = TRUE)
d <- game_filter( Games,
clean_games = TRUE,
clean_ABVD = FALSE,
clean_GS = FALSE,
clean_origin = "only_nonlocal",
clean_pulotu = FALSE,
clean_pulotu_time_0 = FALSE,
clean_pulotu_time_50 = FALSE,
clean_phylo = TRUE
)
```


# Getting help
For further help on the filtering options and data contents, see `?game_filter` `?Games` `?Descriptions` `?Cultures` `?Sources` and `?AustroGames`. Also see our publication (URL coming soon) for more information on data collection and data coding.

Loading

0 comments on commit c947466

Please sign in to comment.