Skip to content

Commit c947466

Browse files
committed
Foreign to nonlocal in data and code
1 parent 42a9bb2 commit c947466

File tree

8 files changed

+171
-163
lines changed

8 files changed

+171
-163
lines changed

R/data.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @description The package applies filters from the Leisterer-Peoples et
77
#' al. (submitted) publication. The \code{game_filter} filters the games in
88
#' several optional steps. Filters include: (non-)games, ABVD codes, goal
9-
#' structure coding, foreign games, matching the game ABVDs with ABVDs from
9+
#' structure coding, introduced games, matching the game ABVDs with ABVDs from
1010
#' Pulotu, matching the time frames of games to those from the
1111
#' open-access Pulotu dataset on figshare (version: 2015) with either 0 or
1212
#' 50 years added, and matching the ABVDs from the games with those from the
@@ -100,13 +100,13 @@ NULL
100100
#' \item{\code{Goal_uncertainty}}{Uncertainty in the goal structure coding
101101
#' (1 = uncertainty)}
102102
#' \item{\code{Goal_comments}}{Comments regarding the goal structure coding}
103-
#' \item{\code{Foreign_keywords}}{Indicates which keywords were found in the
103+
#' \item{\code{Introduced_keywords}}{Indicates which keywords were found in the
104104
#' game description(s)}
105-
#' \item{\code{Foreign_coding}}{Whether the game description(s) indicate
106-
#' foreign origin (foreign, not foreign, undetermined)}
107-
#' \item{\code{Foreign_uncertainty}}{Uncertainty in the foreign coding
105+
#' \item{\code{Introduced_coding}}{Whether the game description(s) indicate
106+
#' non-local origin (non-local, local, undetermined)}
107+
#' \item{\code{Introduced_uncertainty}}{Uncertainty in the introduced coding
108108
#' (1 = uncertainty)}
109-
#' \item{\code{Foreign_comments}}{Comments regarding the foreign coding}
109+
#' \item{\code{Introduced_comments}}{Comments regarding the introduced coding}
110110
#' \item{\code{Pulotu_time_ok_0}}{Indicates whether the "traditional" time
111111
#' frame from Pulotu matches the time frame(s) from the game
112112
#' (1 = same time frame, 0 = different time frames)}

R/game_filter.R

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
#' games with an ABVD code.
1010
#' @param clean_GS logical, default set to FALSE. If TRUE, only include games
1111
#' with a goal structure code.
12-
#' @param clean_foreign several options. \code{remove_foreign} removes only
13-
#' the games that were coded foreign. \code{only_foreign} removes all games
14-
#' except those coded as foreign. \code{coded_nonforeign} removes all games
15-
#' except those that were coded as not being foreign. \code{keep_all} keeps
16-
#' all of the games without any foreign filter.
12+
#' @param clean_origin several options. \code{remove_nonlocal} removes only
13+
#' the games that were coded non-local, but keeps those that were undetermined
14+
#' or NA. \code{only_nonlocal} removes all games except those coded as
15+
#' introduced \code{only_local} removes all games except those that were
16+
#' coded as local. \code{keep_all} keeps all of the games without any
17+
#' origin filter.
1718
#' @param clean_pulotu logical, default set to FALSE. If TRUE, includes games
1819
#' with an ABVD code that matches ABVD codes from Pulotu (Pulotu version:
1920
#' 2015).
@@ -31,15 +32,15 @@
3132
#' Taxonomy.
3233
#' @seealso \url{https://github.com/ccp-eva/AustronesianGames}
3334
#' @examples
34-
#' game_filter(Games, clean_games = TRUE, clean_foreign = "keep_all")
35-
#' game_filter(Games, clean_games = TRUE, clean_foreign = "remove_foreign",
35+
#' game_filter(Games, clean_games = TRUE, clean_origin = "keep_all")
36+
#' game_filter(Games, clean_games = TRUE, clean_origin = "remove_nonlocal",
3637
#' clean_pulotu = TRUE,
3738
#' clean_pulotu_time_50 = TRUE)
38-
#' game_filter(Games, clean_games = TRUE, clean_foreign = "only_foreign",
39+
#' game_filter(Games, clean_games = TRUE, clean_origin = "only_nonlocal",
3940
#' clean_pulotu = TRUE,
4041
#' clean_pulotu_time_0 = TRUE)
4142

42-
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 ){
43+
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 ){
4344

4445
if( clean_games == TRUE ){
4546
Games <- Games[ which( Games$Game == "1" ), ]
@@ -50,17 +51,17 @@ game_filter <- function( ... , clean_games = FALSE , clean_ABVD = FALSE , clean_
5051
if( clean_GS == TRUE ){
5152
Games <- Games[ which( !is.na( Games$Goal_structure )), ]
5253
}
53-
if( clean_foreign == "remove_foreign" ){
54-
Games <- Games[ which( Games$Foreign_coding == "not_foreign" | Games$Foreign_coding == "undetermined" | is.na( Games$Foreign_coding )), ]
54+
if( clean_origin == "remove_nonlocal" ){
55+
Games <- Games[ which( Games$Introduced_coding == "local" | Games$Introduced_coding == "undetermined" | is.na( Games$Introduced_coding )), ]
5556
}
56-
if( clean_foreign == "only_foreign" ){
57-
Games <- Games[ which( Games$Foreign_coding == "foreign" ), ]
57+
if( clean_origin == "only_nonlocal" ){
58+
Games <- Games[ which( Games$Introduced_coding == "nonlocal" ), ]
5859
}
59-
if( clean_foreign == "coded_nonforeign" ){
60-
Games <- Games[ which( Games$Foreign_coding == "not_foreign" ), ]
60+
if( clean_origin == "only_local" ){
61+
Games <- Games[ which( Games$Introduced_coding == "local" ), ]
6162
}
62-
if( clean_foreign == "keep_all" ){
63-
paste0( "keep all: no foreign filter applied" )
63+
if( clean_origin == "keep_all" ){
64+
paste0( "keep all: no origin filter applied" )
6465
}
6566
if( clean_pulotu == TRUE ){
6667
Games <- Games[ which( Games$Game_ID %in% unlist( strsplit( Cultures$Game_ID[ which( !is.na( Cultures$Pulotu_culture ))], ";" ))),]

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ To use the game filter and access the game data, you need to install the `devtoo
1212
```r
1313
install.packages("devtools")
1414
```
15-
or from the development version on GitHub
16-
```r
17-
devtools::install_github("r-lib/devtools")
18-
```
1915

2016
Then you can install the AustroGames package:
2117
```r
@@ -30,21 +26,31 @@ data(Descriptions)
3026
data(Cultures)
3127
data(Sources)
3228
```
33-
The data can be viewed:
29+
The data can be examined further:
3430
```r
3531
str(Games)
36-
str(Descriptions)
37-
str(Cultures)
38-
str(Sources)
32+
head(Games)
33+
dim(Games)
34+
colnames(Games)
3935
```
4036

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

43-
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).
39+
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).
4440
```r
45-
d <- game_filter(Games, clean_games = TRUE, clean_foreign = "only_foreign", clean_phylo = TRUE)
41+
d <- game_filter( Games,
42+
clean_games = TRUE,
43+
clean_ABVD = FALSE,
44+
clean_GS = FALSE,
45+
clean_origin = "only_nonlocal",
46+
clean_pulotu = FALSE,
47+
clean_pulotu_time_0 = FALSE,
48+
clean_pulotu_time_50 = FALSE,
49+
clean_phylo = TRUE
50+
)
4651
```
4752

53+
4854
# Getting help
4955
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.
5056

0 commit comments

Comments
 (0)