首页 > 解决方案 > R向现有的S4对象添加一个新槽

问题描述

我试图遵循这个答案,但迷路了。请问有人可以拼出我的具体输入吗?

我有以下称为“经典”的 S4 对象:

> 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"

我可以编辑现有插槽的内容,例如:

classic@description = "Custom Afol today"

但是,我想添加一个名为“本体”的新插槽,其字符输入为“BP”。有没有办法为这样的现有对象添加一个新插槽?

标签: rs4

解决方案


推荐阅读