Skip to contents

Show all variables with no variation in their values within each data frame of the list of data frames (except the ones in the info list). This function is useful for identifying unnecessary variables before running an experiment. It allows checking for columns with any unchanging value or only a specific value.

Usage

show_constant(oTree, value = "any")

Arguments

oTree

A list of data frames created with import_otree().

value

The value that is controlled to be the same within a column. If the value is set to "any", the function checks for columns where any possible values are identical.

Value

This function returns a list of vectors, one for each app, $all_apps_wide, the $Time and/or the $Chats data frame. Each vector contains the names of all variables with constant values. If there are no variables with constant values, the vector is empty.

Examples

# Use package-internal list of oTree data frames
oTree <- gmoTree::oTree

# Show all columns that contain only NAs
show_constant(oTree = oTree)
#> $all_apps_wide
#>  [1] "participant._is_bot"                         
#>  [2] "participant._max_page_index"                 
#>  [3] "participant.visited"                         
#>  [4] "participant.mturk_worker_id"                 
#>  [5] "participant.mturk_assignment_id"             
#>  [6] "session.label"                               
#>  [7] "session.mturk_HITId"                         
#>  [8] "session.mturk_HITGroupId"                    
#>  [9] "session.comment"                             
#> [10] "session.is_demo"                             
#> [11] "session.config.name"                         
#> [12] "session.config.real_world_currency_per_point"
#> [13] "session.config.participation_fee"            
#> [14] "dictator.1.player.role"                      
#> [15] "dictator.1.subsession.round_number"          
#> [16] "dictator.2.player.role"                      
#> [17] "dictator.2.subsession.round_number"          
#> [18] "dictator.3.player.role"                      
#> [19] "dictator.3.subsession.round_number"          
#> [20] "chatapp.1.player.role"                       
#> [21] "chatapp.1.player.payoff"                     
#> [22] "chatapp.1.subsession.round_number"           
#> [23] "survey.1.player.role"                        
#> [24] "survey.1.player.payoff"                      
#> [25] "survey.1.group.id_in_subsession"             
#> [26] "survey.1.subsession.round_number"            
#> 
#> $chatapp
#>  [1] "participant._is_bot"             "participant._max_page_index"    
#>  [3] "participant.visited"             "participant.mturk_worker_id"    
#>  [5] "participant.mturk_assignment_id" "player.role"                    
#>  [7] "player.payoff"                   "subsession.round_number"        
#>  [9] "session.label"                   "session.mturk_HITId"            
#> [11] "session.mturk_HITGroupId"        "session.comment"                
#> [13] "session.is_demo"                
#> 
#> $dictator
#>  [1] "participant._is_bot"             "participant._max_page_index"    
#>  [3] "participant.visited"             "participant.mturk_worker_id"    
#>  [5] "participant.mturk_assignment_id" "player.role"                    
#>  [7] "session.label"                   "session.mturk_HITId"            
#>  [9] "session.mturk_HITGroupId"        "session.comment"                
#> [11] "session.is_demo"                
#> 
#> $survey
#>  [1] "participant._is_bot"             "participant._max_page_index"    
#>  [3] "participant.visited"             "participant.mturk_worker_id"    
#>  [5] "participant.mturk_assignment_id" "player.role"                    
#>  [7] "player.payoff"                   "group.id_in_subsession"         
#>  [9] "subsession.round_number"         "session.label"                  
#> [11] "session.mturk_HITId"             "session.mturk_HITGroupId"       
#> [13] "session.comment"                 "session.is_demo"                
#> 
#> $Time
#> [1] "timeout_happened"
#> 
#> $Chats
#> character(0)
#> 
show_constant(oTree = oTree, value = NA)
#> $all_apps_wide
#>  [1] "participant.mturk_worker_id"     "participant.mturk_assignment_id"
#>  [3] "session.label"                   "session.mturk_HITId"            
#>  [5] "session.mturk_HITGroupId"        "session.comment"                
#>  [7] "dictator.1.player.role"          "dictator.2.player.role"         
#>  [9] "dictator.3.player.role"          "chatapp.1.player.role"          
#> [11] "survey.1.player.role"           
#> 
#> $chatapp
#> [1] "participant.mturk_worker_id"     "participant.mturk_assignment_id"
#> [3] "player.role"                     "session.label"                  
#> [5] "session.mturk_HITId"             "session.mturk_HITGroupId"       
#> [7] "session.comment"                
#> 
#> $dictator
#> [1] "participant.mturk_worker_id"     "participant.mturk_assignment_id"
#> [3] "player.role"                     "session.label"                  
#> [5] "session.mturk_HITId"             "session.mturk_HITGroupId"       
#> [7] "session.comment"                
#> 
#> $survey
#> [1] "participant.mturk_worker_id"     "participant.mturk_assignment_id"
#> [3] "player.role"                     "session.label"                  
#> [5] "session.mturk_HITId"             "session.mturk_HITGroupId"       
#> [7] "session.comment"                
#> 
#> $Time
#> character(0)
#> 
#> $Chats
#> character(0)
#> 

# Show all columns that contain only -99
show_constant(oTree = oTree, value = -99)
#> $all_apps_wide
#> character(0)
#> 
#> $chatapp
#> character(0)
#> 
#> $dictator
#> character(0)
#> 
#> $survey
#> character(0)
#> 
#> $Time
#> character(0)
#> 
#> $Chats
#> character(0)
#>