R adding slots to existing S4 object

Viewed 218

I am trying to follow this answer but getting lost with what to change for my example. Please can someone spell out specifically for the below?

I have the following S4 object called "classic":

> str(classic)
Formal class 'topGOresult' [package "topGO"] with 5 slots
  ..@ description: chr "Custom Afol today"
  ..@ score      : Named num [1:7633] 0.5735 0.0883 0.8081 0.8005 0.4941 ...
  .. ..- attr(*, "names")= chr [1:7633] "GO:0000002" "GO:0000003" "GO:0000018" "GO:0000027" ...
  ..@ testName   : chr "fisher"
  ..@ algorithm  : chr "classic"
  .. ..- attr(*, "testClass")= chr "classicCount"
  ..@ geneData   : Named int [1:4] 9171 620 5 5361
  .. ..- attr(*, "names")= chr [1:4] "Annotated" "Significant" "NodeSize" "SigTerms"

I am able to edit contents of existing slots, such as:

classic@description = "Custom Afol today"

However, I would like to add a new slot called "ontology" with character input of "BP". Is there a way to add a new slot to an existing object such as this?

Many thanks in advance for help.

0 Answers
Related