Skip to content

Commit a8dd24d

Browse files
committed
Convert wordbankr item_id to integer
1 parent c66b9b2 commit a8dd24d

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

ipl/media/uploads/instruments/generateInstrumentFiles.r

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,28 @@ type <- "WS" # "WS" or "WG"
1313
resp <- "production" # "comprehension" or "production"
1414

1515
d_poly <- 3
16-
poly_mode <- "Flexi" #"Fixed" #"Fixed" # or
16+
poly_mode <- "Flexi" # "Fixed" or "Flexi"
1717
criteria <- "incl.anyFinite" # or "excl.Inf" — for evaluation of log = -inf
1818
gen_list <- c("Female", "Male")
1919

2020
########## Functions
21+
# Convert item_id to an integer
22+
convert_item_id <- function(data) {
23+
data %>%
24+
mutate(item_id = as.integer(gsub("item_", "", item_id)))
25+
}
26+
2127
# Get data from word bank
2228
prep_data <- function(){
2329
admin_ws <<- get_administration_data(lang, type, include_demographic_info = TRUE)
2430
if(lang == "English (American)"){
2531
admin_ws <<- admin_ws #%>% filter(norming=="TRUE")
2632
}
27-
data_ws <<- get_instrument_data(lang, type)
33+
data_ws <<- get_instrument_data(lang, type) %>% convert_item_id
2834
if(lang == "English (American)"){
2935
data_ws <<- data_ws %>% filter(data_id %in% admin_ws$data_id)
3036
}
31-
items_ws <<- get_item_data(lang, type)
37+
items_ws <<- get_item_data(lang, type) %>% convert_item_id
3238

3339
# reduce datasets
3440
items_ws <<- subset(items_ws, item_kind=="word")
@@ -424,7 +430,7 @@ for (i in 1:(length(items@ParObjects$pars) - 1)){
424430
rownames(irtparam) <- 1:nrow(irtparam)
425431

426432
IRT_Parameters <- irtparam %>% data.frame() %>%
427-
mutate(word_id = gsub(pattern = "item_", replacement = "", x = names(data_irt))) %>%
433+
mutate(word_id = as.integer(names(data_irt))) %>%
428434
select(word_id, colnames(.[,1:(ncol(.)-1)]))
429435

430436
if (type == "WG") {

0 commit comments

Comments
 (0)