Skip to contents

parse_netlogo_list() parses NetLogo-style lists represented as strings (e.g., "[1 2 3]") into R lists. It automatically detects numeric, integer, logical, and character types within the lists and converts them accordingly.

If the input does not contain NetLogo-style lists, it returns the original vector unchanged.

Usage

parse_netlogo_list(x)

Arguments

x

An atomic object potentially containing NetLogo-style lists.

Value

A list of parsed elements if the input contains NetLogo-style lists; otherwise, returns the original vector.

See also

Other Utility functions: inspect_experiment_file()

Examples

# Scalar Examples -----

'["a" "b" "c"]' |> parse_netlogo_list()
#> [[1]]
#> [1] "a" "b" "c"
#> 

'[1 2 3]' |> parse_netlogo_list()
#> [[1]]
#> [1] 1 2 3
#> 

'[1.1 2.1 3.1]' |> parse_netlogo_list()
#> [[1]]
#> [1] 1.1 2.1 3.1
#> 

'[true false true]' |> parse_netlogo_list()
#> [[1]]
#> [1]  TRUE FALSE  TRUE
#> 

# Vector Examples -----

c('["a" "b" "c"]', '["d" "e" "f"]') |> parse_netlogo_list()
#> [[1]]
#> [1] "a" "b" "c"
#> 
#> [[2]]
#> [1] "d" "e" "f"
#> 

c('[1 2 3]', '[4 5 6]') |> parse_netlogo_list()
#> [[1]]
#> [1] 1 2 3
#> 
#> [[2]]
#> [1] 4 5 6
#> 

c('[1.1 2.1 3.1]', '[4.1 5.1 6.1]') |> parse_netlogo_list()
#> [[1]]
#> [1] 1.1 2.1 3.1
#> 
#> [[2]]
#> [1] 4.1 5.1 6.1
#> 

c('[true false true]', '[false true false]') |> parse_netlogo_list()
#> [[1]]
#> [1]  TRUE FALSE  TRUE
#> 
#> [[2]]
#> [1] FALSE  TRUE FALSE
#>