Skip to main content

Questions tagged [r-s4]

One of the methods of object oriented programming in the R language.

4 votes
1 answer
100 views

Is there a way to prevent modification of an S4 object in R?

I want to create an S4 class that is a subclass of another S4 class, with additional constraints (like the object should be sorted). Given that modifications of the object could result in violations ...
CuriousTim's user avatar
1 vote
1 answer
26 views

How do I override auto formats in TERN functions like count_patients_with_flags?

TERN (Rtables) Package Formatting Functions Anyone here familiar with overriding auto formats in TERN functions like count_patients_with_flags? lyt_adae <- basic_table(show_colcounts = TRUE) %>% ...
Dimple Patel's user avatar
1 vote
1 answer
84 views

Overriding the subset method in R for a specific class interferes with other objects

I am working with R and I have created a new subset method for objects of class new_object. Here is my function: setGeneric('subset', function(x, i) standardGeneric('subset')) setMethod('subset', '...
zhang's user avatar
  • 443
0 votes
0 answers
54 views

rewriting R6 to S4 class in R

I have this function here person1$check_infection(person2) person1 and person2 are R6 class objects, I have already rewritten the check_infection method in S4, how do I write the above function in S4?...
B.M Njuguna's user avatar
1 vote
0 answers
63 views

How to document a method in R using Roxygen2 when the class and generic live in another package?

How does one document a method for a class defined in another package? For example, I've written a method for the QDNAseqSignals class defined in the QDNAseq. I want to document this method using ...
user22080160's user avatar
0 votes
1 answer
51 views

add personal funtion in setMethod in R

I have and new S4 object with 4 Slots, one of them is a data.frame (g_table), so I want to add a parameters to setMethod to subset the data: this is my actual code: setGeneric('g_table', function(x) ...
abraham's user avatar
  • 723
0 votes
0 answers
36 views

(R) Finding list elements by name and combine list elements into c()

I have an S4 object named "S4" that contains the id and a list (or it can be changed into a data frame) named "color" that has the color information annotated to each id in R. # S4 ...
H.J 's user avatar
  • 1
0 votes
1 answer
36 views

Using the `validate` package inside an Rmarkdown document

I wish to include same validations inside my Rmarkdown report. Here is a minimal example: --- title: "My Report" output: html_document: mode: selfcontained theme: null --- ```{r, ...
Karsten W.'s user avatar
  • 18.2k
0 votes
0 answers
409 views

Subcluster all the clusters of a Seurat object

I have a Seurat object made from integrating 4 different objects, the results is a Seurat object with 70 clusters (0 to 69) I wanted to subset each single cluster and recluster it to achieve higher ...
AvolaAMG's user avatar
0 votes
0 answers
119 views

How can I convert a RS4 object to python data frame?

I am trying to perform DGE analysis with Deseq2 in python using the rpy2 package. I have currently managed to reach the step where I have my results in the RS4 object format. Ideally now I would like ...
Eleana Rizou's user avatar
0 votes
0 answers
37 views

S4 method for ensuring dplyr distinct selects rows containing distinct S4 objects

I am implementing an S4 class called Taxa. Objects of class Taxa form a column in a tbl_df. For example: my_tbl <- tibble::tibble(taxa = list(Taxa(Taxon(family = "test")), Taxa(Taxon(...
Bryce Frank's user avatar
0 votes
0 answers
67 views

Issue with `mclapply` in R package S4 implementation when passing strings

I am developing an R package that utilizes S4 classes and methods. In one of the methods, I am using mclapply from the parallel package to process data in parallel. This method has an if-else nest ...
sp29's user avatar
  • 383
0 votes
1 answer
43 views

R Error message 'argument fdef is missing with no default`

The following code fails with the error message shown above. #' Generic setter for XiFit class #' #' @param knots Knots object to which weights are applied #' @param weights Given weights #' #' @...
JeremyC's user avatar
  • 457
1 vote
2 answers
73 views

Generating similar methods via loop in R package

I tried to write a for loop to create getters and setters for slots of an S4 class. A similar reprex with a smaller class and only methods for the getters is: library(methods) library(testthat) ...
Julian Grimm's user avatar
5 votes
1 answer
73 views

Is there a way to use own package's data (internal or external) as a default S4 class slot?

Is there a way to use my own package's data (internal or external) as a default S4 class slot? If I create some package data: my_pkg_data <- sample(100) usethis::use_data(my_pkg_data, internal=...
Nicholas Sunderland's user avatar

15 30 50 per page
1
2 3 4 5
45