rcpp_areas_list_to_states_list {cladoRcpp}R Documentation

Make a list of 0-based indices of possible combinations of input areas

Description

Given a list of areas (actually a list of anything; all that is important is the length of the list) rcpp_areas_list_to_states_list calculates all possible combinations of these areas, listing them by the 0-based indices that specify the position of each area in the list.

Usage

rcpp_areas_list_to_states_list(areas = c("A", "B", "C"),
  maxareas = length(areas), include_null_range = TRUE)

Arguments

areas

a list of areas (character or number; the function converts these to numbers, starting with 0)

maxareas

maximum number of areas in this analyses

include_null_range

TRUE or FALSE, should the NULL range be included in the possible states? (e.g., LAGRANGE default is yes)

Details

Using 0-based indexing is convenient in the C++ code called by the other functions, rather than having to keep track of the various people might label their areas (names, abbreviations, letters, numbers).

As in LAGRANGE (Ree & Smith 2008), the maximum range size (i.e. the maximum number of areas in a range) can be specified by the user. Having a smaller maximum range size drastically reduces the number of states, and thus the size of the transition matrix and the cladogenesis matrix.

Value

R_states_list A list of the states, where each state is a list of areas in the form of 0-based indices

Author(s)

Nicholas Matzke matzke@berkeley.edu

See Also

numstates_from_numareas, areas_list_to_states_list_old #bibliography /Dropbox/_njm/__packages/cladoRcpp_setup/cladoRcpp_refs.bib @cite Matzke_2013 @cite Matzke_2014 @cite ReeSmith2008

Examples

# Specify the areas
areas_list = c("A", "B", "C")
areas_list

# Let's try Rcpp_combn_zerostart, in case that is the source of a
# problem found via AddressSanitizer
Rcpp_combn_zerostart(n_to_choose_from=4, k_to_choose=2, maxlim=1e+07)
Rcpp_combn_zerostart(n_to_choose_from=4, k_to_choose=3, maxlim=1e+07)


## Not run: 

# Calculate the list of 0-based indices for each possible geographic range, i.e.
# each combination of areas
states_list = rcpp_areas_list_to_states_list(areas=areas_list, maxareas=3, 
include_null_range=FALSE)
states_list
states_list = rcpp_areas_list_to_states_list(areas=areas_list, maxareas=3, 
include_null_range=TRUE)
states_list
states_list = rcpp_areas_list_to_states_list(areas=areas_list, maxareas=2, 
include_null_range=TRUE)
states_list
states_list = rcpp_areas_list_to_states_list(areas=areas_list, maxareas=1, 
include_null_range=TRUE)
states_list


## End(Not run)


[Package cladoRcpp version 0.15.1 Index]