@@ -1246,18 +1246,20 @@ Rcpp::List rtsk_table_collection_metadata_length(const SEXP tc) {
12461246// @param flags passed to \code{tskit C}.
12471247// @param location numeric vector with the location of the new individual
12481248// (can be \code{NULL}).
1249- // @param parents integer vector with parent individual IDs
1249+ // @param parents integer vector with parent individual IDs (0-based)
12501250// (can be \code{NULL}).
12511251// @param metadata raw vector with metadata bytes
12521252// (can be \code{NULL}).
12531253// @details This function calls
12541254// \url{https://tskit.dev/tskit/docs/stable/c-api.html#c.tsk_individual_table_add_row}
12551255// on the individuals table of \code{tc}.
1256- // @return The 0-based row ID of the newly added individual.
1256+ // @return The row ID (0-based) of the newly added individual.
12571257// @examples
12581258// ts_file <- system.file("examples/test.trees", package = "RcppTskit")
12591259// tc_xptr <- RcppTskit:::rtsk_table_collection_load(ts_file)
12601260// n_before <- RcppTskit:::rtsk_table_collection_get_num_individuals(tc_xptr)
1261+ // m_before
1262+ // <- RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)$individuals
12611263// tc_py <- RcppTskit:::rtsk_table_collection_r_to_py(tc_xptr)
12621264// tc_py$individuals$max_rows
12631265// tc_py$individuals["flags"]
@@ -1279,8 +1281,13 @@ Rcpp::List rtsk_table_collection_metadata_length(const SEXP tc) {
12791281// new_id <- RcppTskit:::rtsk_individual_table_add_row(tc = tc_xptr, flags = 3L,
12801282// location = c(2, 11), parents = c(1L, 3L), metadata = charToRaw("abc"))
12811283// n_after <- RcppTskit:::rtsk_table_collection_get_num_individuals(tc_xptr)
1282- // new_id == as.integer(n_before) && n_after == n_before + 3L
1283- // tc_py <- RcppTskit:::rtsk_table_collection_r_to_py(tc_xptr)
1284+ // m_after <-
1285+ // RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)$individuals
1286+ // new_id == n_after - 1L
1287+ // n_after == n_before + 3L
1288+ // m_after == m_before + 3L
1289+ // tc_py <-
1290+ // RcppTskit:::rtsk_table_collection_r_to_py(tc_xptr)
12841291// tc_py$individuals$max_rows
12851292// tc_py$individuals["flags"]
12861293// tc_py$individuals["location"]
@@ -1340,18 +1347,21 @@ int rtsk_individual_table_add_row(
13401347// \code{tsk_table_collection_t} object.
13411348// @param flags passed to \code{tskit C}.
13421349// @param time numeric time value for the new node.
1343- // @param population integer population row ID (0-based, or \code{-1}).
1344- // @param individual integer individual row ID (0-based, or \code{-1}).
1350+ // @param population integer population row ID (0-based);
1351+ // use \code{-1} if not known.
1352+ // @param individual integer individual row ID (0-based);
1353+ // use \code{-1} if not known.
13451354// @param metadata raw vector with metadata bytes
13461355// (can be \code{NULL}).
13471356// @details This function calls
13481357// \url{https://tskit.dev/tskit/docs/stable/c-api.html#c.tsk_node_table_add_row}
13491358// on the nodes table of \code{tc}.
1350- // @return The 0-based row ID of the newly added node.
1359+ // @return The row ID (0-based) of the newly added node.
13511360// @examples
13521361// ts_file <- system.file("examples/test.trees", package = "RcppTskit")
13531362// tc_xptr <- RcppTskit:::rtsk_table_collection_load(ts_file)
13541363// n_before <- RcppTskit:::rtsk_table_collection_get_num_nodes(tc_xptr)
1364+ // m_before <- RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)$nodes
13551365// tc_py <- RcppTskit:::rtsk_table_collection_r_to_py(tc_xptr)
13561366// tc_py$nodes$max_rows
13571367// tc_py$nodes["flags"]
@@ -1370,7 +1380,10 @@ int rtsk_individual_table_add_row(
13701380// metadata = charToRaw("abc")
13711381// )
13721382// n_after <- RcppTskit:::rtsk_table_collection_get_num_nodes(tc_xptr)
1373- // new_id == as.integer(n_before) && n_after == n_before + 3L
1383+ // m_after <- RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)$nodes
1384+ // new_id == n_after - 1L
1385+ // n_after == n_before + 4L
1386+ // m_after == m_before + 3L
13741387// tc_py <- RcppTskit:::rtsk_table_collection_r_to_py(tc_xptr)
13751388// tc_py$nodes$max_rows
13761389// tc_py$nodes["flags"]
@@ -1428,27 +1441,29 @@ int rtsk_node_table_add_row(
14281441// @details This function calls
14291442// \url{https://tskit.dev/tskit/docs/stable/c-api.html#c.tsk_edge_table_add_row}
14301443// on the edges table of \code{tc}.
1431- // @return The 0-based row ID of the newly added edge.
1444+ // @return The row ID (0-based) of the newly added edge.
14321445// @examples
14331446// ts_file <- system.file("examples/test.trees", package = "RcppTskit")
14341447// tc_xptr <- RcppTskit:::rtsk_table_collection_load(ts_file)
1435- // parent <- 0L
1436- // child <- 1L
1448+ // child <- rtsk_node_table_add_row(tc_xptr, time = 0.0)
14371449// n_before <- RcppTskit:::rtsk_table_collection_get_num_edges(tc_xptr)
1438- // m_before <-
1439- // RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)[["edges"]] new_id
1440- // <- RcppTskit:::rtsk_edge_table_add_row(
1441- // tc = tc_xptr, left = 0, right = 1, parent = parent, child = child
1450+ // m_before <- RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)$edges
1451+ // new_id <- RcppTskit:::rtsk_edge_table_add_row(
1452+ // tc = tc_xptr, left = 0, right = 50, parent = 16L, child = child
14421453// )
14431454// new_id <- RcppTskit:::rtsk_edge_table_add_row(
1444- // tc = tc_xptr, left = 1, right = 2, parent = parent, child = child,
1445- // metadata = charToRaw("abc")
1455+ // tc = tc_xptr, left = 50, right = 75, parent = 17L, child = child,
1456+ // metadata = "abc"
1457+ // )
1458+ // new_id <- RcppTskit:::rtsk_edge_table_add_row(
1459+ // tc = tc_xptr, left = 75, right = 100, parent = 18L, child = child,
1460+ // metadata = charToRaw("cba")
14461461// )
14471462// n_after <- RcppTskit:::rtsk_table_collection_get_num_edges(tc_xptr)
1448- // m_after <-
1449- // RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)[["edges"]] new_id
1450- // == as.integer(n_before) && n_after == n_before + 2L && m_after == m_before +
1451- // 3L
1463+ // m_after <- RcppTskit:::rtsk_table_collection_metadata_length(tc_xptr)$edges
1464+ // new_id == n_after - 1L
1465+ // n_after == n_before + 3L
1466+ // m_after == m_before + 3L
14521467// [[Rcpp::export]]
14531468int rtsk_edge_table_add_row (
14541469 const SEXP tc, const double left, const double right, const int parent,
0 commit comments