Skip to content

Instantly share code, notes, and snippets.

@lilywang1988
Last active May 27, 2018 15:18
Show Gist options
  • Save lilywang1988/710c0b144d84263d95ce570c23c4c13a to your computer and use it in GitHub Desktop.
Save lilywang1988/710c0b144d84263d95ce570c23c4c13a to your computer and use it in GitHub Desktop.
How to creat List in Rcpp

How to create List in Rcpp? 3 Ways!

1. Create the List directly and define the components

List res;
  res["beta1_scr"] = beta1_scr;
  res["beta2_scr"] = beta2_scr;
  res["beta1_inf"] = beta1_inf;
  res["beta2_inf"] = beta2_inf;
  res["r_scr"] =  r_scr;
  res["r_inf"] =  r_inf;
  res["beta1_r_inf"] =beta1_r_inf;
  res["beta2_r_inf"] =beta2_r_inf;
  return(res);

2. Create the List and its components altogether

2.1 Without renaming

return(List::create(hit_table, hit_count, hit_utility,hit_t_table, hit_t_count, hit_t_utility,ARL_rho,ARL_rho_index,ARL_rho_t,ARL_rho_t_index));

2.2 With renaming

return(List::create(Named("hit_table")=hit_table, _["hit_count"]=hit_count, _["hit_utility"]=hit_utility));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment