@@ -138,7 +138,7 @@ TableCollection <- R6Class(
138138 rtsk_table_collection_get_num_provenances(self $ xptr )
139139 },
140140
141- # ' @description Add a row to the provenances table.
141+ # ' @description Add a row to the provenance table.
142142 # ' @param timestamp character string timestamp for the new provenance.
143143 # ' @param record character string record for the new provenance.
144144 # ' @details See the \code{tskit Python} equivalent at
@@ -163,10 +163,18 @@ TableCollection <- R6Class(
163163 )
164164 },
165165
166- # ' @description Get one row from the provenances table.
167- # ' @param index integer scalar row index (0-based).
166+ # ' @description Get one row from the provenance table.
167+ # ' @param index integer or numeric scalar row index (0-based).
168+ # ' @details See the \code{tskit Python} equivalent at
169+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.ProvenanceTable.__getitem__}.
170+ # ' The function accepts numeric \code{index} for ease of use, but converts
171+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
168172 # ' @return A named list with fields \code{id}, \code{timestamp},
169173 # ' and \code{record}.
174+ # ' @examples
175+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
176+ # ' tc <- tc_load(ts_file)
177+ # ' tc$provenance_table_get_row(0)
170178 provenance_table_get_row = function (index ) {
171179 validate_row_index(index )
172180 rtsk_provenance_table_get_row(self $ xptr , index = as.integer(index ))
@@ -204,9 +212,17 @@ TableCollection <- R6Class(
204212 )
205213 },
206214
207- # ' @description Get one row from the populations table.
208- # ' @param index integer scalar row index (0-based).
215+ # ' @description Get one row from the population table.
216+ # ' @param index integer or numeric scalar row index (0-based).
217+ # ' @details See the \code{tskit Python} equivalent at
218+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.PopulationTable.__getitem__}.
219+ # ' The function accepts numeric \code{index} for ease of use, but converts
220+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
209221 # ' @return A named list with fields \code{id} and \code{metadata}.
222+ # ' @examples
223+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
224+ # ' tc <- tc_load(ts_file)
225+ # ' tc$population_table_get_row(0)
210226 population_table_get_row = function (index ) {
211227 validate_row_index(index )
212228 rtsk_population_table_get_row(self $ xptr , index = as.integer(index ))
@@ -287,11 +303,24 @@ TableCollection <- R6Class(
287303 )
288304 },
289305
290- # ' @description Get one row from the migrations table.
291- # ' @param index integer scalar row index (0-based).
306+ # ' @description Get one row from the migration table.
307+ # ' @param index integer or numeric scalar row index (0-based).
308+ # ' @details See the \code{tskit Python} equivalent at
309+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.MigrationTable.__getitem__}.
310+ # ' The function accepts numeric \code{index} for ease of use, but converts
311+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
292312 # ' @return A named list with fields \code{id}, \code{left}, \code{right},
293313 # ' \code{node}, \code{source}, \code{dest}, \code{time}, and
294314 # ' \code{metadata}.
315+ # ' @examples
316+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
317+ # ' tc <- tc_load(ts_file)
318+ # ' if (as.integer(tc$num_migrations()) == 0L) {
319+ # ' tc$migration_table_add_row(
320+ # ' left = 0, right = 1, node = 0L, source = 0L, dest = 0L, time = 1
321+ # ' )
322+ # ' }
323+ # ' tc$migration_table_get_row(0)
295324 migration_table_get_row = function (index ) {
296325 validate_row_index(index )
297326 rtsk_migration_table_get_row(self $ xptr , index = as.integer(index ))
@@ -348,13 +377,22 @@ TableCollection <- R6Class(
348377 )
349378 },
350379
351- # ' @description Get one row from the individuals table.
352- # ' @param index integer scalar row index (0-based).
380+ # ' @description Get one row from the individual table.
381+ # ' @param index integer or numeric scalar row index (0-based).
382+ # ' @details See the \code{tskit Python} equivalent at
383+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.IndividualTable.__getitem__}.
384+ # ' The function accepts numeric \code{index} for ease of use, but converts
385+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
353386 # ' @return A named list with fields \code{id}, \code{flags},
354387 # ' \code{location}, \code{parents}, and \code{metadata}.
388+ # ' @examples
389+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
390+ # ' tc <- tc_load(ts_file)
391+ # ' tc$individual_table_get_row(0)
355392 individual_table_get_row = function (index ) {
356393 validate_row_index(index )
357- rtsk_individual_table_get_row(self $ xptr , index = as.integer(index ))
394+ row <- rtsk_individual_table_get_row(self $ xptr , index = as.integer(index ))
395+ row [c(" id" , " flags" , " location" , " parents" , " metadata" )]
358396 },
359397
360398 # ' @description Get the number of nodes in a table collection.
@@ -432,11 +470,13 @@ TableCollection <- R6Class(
432470 # TODO: Similarly with add_row method on the R side, maybe?
433471 # TODO: ALSO, should we use 0-based or 1-based access to elements of an object!? I think not!?
434472 # And should we allow characters as ID names?
435- # ' @description Get one row from the nodes table.
436- # ' @param index integer scalar row index (0-based).
473+ # ' @description Get one row from the node table.
474+ # ' @param index integer or numeric scalar row index (0-based).
437475 # ' @details In \code{tskit Python}, rows are accessed by indexing a
438476 # ' \code{NodeTable}, for example \code{tables.nodes[index]}; see
439477 # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.NodeTable}.
478+ # ' The function accepts numeric \code{index} for ease of use, but converts
479+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
440480 # ' @return A named list with fields \code{id}, \code{flags}, \code{time},
441481 # ' \code{population}, \code{individual}, and \code{metadata}.
442482 # ' @examples
@@ -510,10 +550,18 @@ TableCollection <- R6Class(
510550 )
511551 },
512552
513- # ' @description Get one row from the edges table.
514- # ' @param index integer scalar row index (0-based).
553+ # ' @description Get one row from the edge table.
554+ # ' @param index integer or numeric scalar row index (0-based).
555+ # ' @details See the \code{tskit Python} equivalent at
556+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.EdgeTable.__getitem__}.
557+ # ' The function accepts numeric \code{index} for ease of use, but converts
558+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
515559 # ' @return A named list with fields \code{id}, \code{left}, \code{right},
516560 # ' \code{parent}, \code{child}, and \code{metadata}.
561+ # ' @examples
562+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
563+ # ' tc <- tc_load(ts_file)
564+ # ' tc$edge_table_get_row(0)
517565 edge_table_get_row = function (index ) {
518566 validate_row_index(index )
519567 rtsk_edge_table_get_row(self $ xptr , index = as.integer(index ))
@@ -560,13 +608,22 @@ TableCollection <- R6Class(
560608 )
561609 },
562610
563- # ' @description Get one row from the sites table.
564- # ' @param index integer scalar row index (0-based).
611+ # ' @description Get one row from the site table.
612+ # ' @param index integer or numeric scalar row index (0-based).
613+ # ' @details See the \code{tskit Python} equivalent at
614+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.SiteTable.__getitem__}.
615+ # ' The function accepts numeric \code{index} for ease of use, but converts
616+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
565617 # ' @return A named list with fields \code{id}, \code{position},
566618 # ' \code{ancestral_state}, and \code{metadata}.
619+ # ' @examples
620+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
621+ # ' tc <- tc_load(ts_file)
622+ # ' tc$site_table_get_row(0)
567623 site_table_get_row = function (index ) {
568624 validate_row_index(index )
569- rtsk_site_table_get_row(self $ xptr , index = as.integer(index ))
625+ row <- rtsk_site_table_get_row(self $ xptr , index = as.integer(index ))
626+ row [c(" id" , " position" , " ancestral_state" , " metadata" )]
570627 },
571628
572629 # ' @description Get the number of mutations in a table collection.
@@ -645,14 +702,31 @@ TableCollection <- R6Class(
645702 )
646703 },
647704
648- # ' @description Get one row from the mutations table.
649- # ' @param index integer scalar row index (0-based).
705+ # ' @description Get one row from the mutation table.
706+ # ' @param index integer or numeric scalar row index (0-based).
707+ # ' @details See the \code{tskit Python} equivalent at
708+ # ' \url{https://tskit.dev/tskit/docs/stable/python-api.html#tskit.MutationTable.__getitem__}.
709+ # ' The function accepts numeric \code{index} for ease of use, but converts
710+ # ' it to integer after checking that conversion to 32-bit integer succeeds.
650711 # ' @return A named list with fields \code{id}, \code{site}, \code{node},
651- # ' \code{parent}, \code{time}, \code{derived_state}, and
652- # ' \code{metadata}.
712+ # ' \code{derived_state}, \code{parent}, \code{metadata}, and
713+ # ' \code{time}.
714+ # ' @examples
715+ # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
716+ # ' tc <- tc_load(ts_file)
717+ # ' tc$mutation_table_get_row(0)
653718 mutation_table_get_row = function (index ) {
654719 validate_row_index(index )
655- rtsk_mutation_table_get_row(self $ xptr , index = as.integer(index ))
720+ row <- rtsk_mutation_table_get_row(self $ xptr , index = as.integer(index ))
721+ row [c(
722+ " id" ,
723+ " site" ,
724+ " node" ,
725+ " derived_state" ,
726+ " parent" ,
727+ " metadata" ,
728+ " time"
729+ )]
656730 },
657731
658732 # ' @description Get the sequence length.
0 commit comments