2013-02-14 44 views

回答

1

件需要:

  • 的所有功能特徵向量:apropos("^",mode="function")
  • 難道一個功能有沒有參數? length(formals(x))==0
  • 抓住一個字符向量lapply(x, get)

感謝@RichieCotton的apropos,並@hadley爲is.primitive命名的對象。

allFxnNames <- apropos("^",mode="function") 
emptyFormals <- function(x) length(formals(x))==0 && !is.primitive(x) 
allFxns <- lapply(allFxnNames, get) 
whichEmpty <- sapply(allFxns, emptyFormals) 
allFxnNames[whichEmpty] 

此找到所有非基本功能沒有正式的參數:

「報警」, 「closeAllConnections」, 「色彩」, 「色彩」, 「貢獻者」, 「Cstack_info」 「日期」, 「defaultPrototype」, 「default.stringsAsFactors」, 「dev.cur」, 「dev.list」, 「dev_packages」, 「element_blank」, 「empty.dump」, 「首先」,」。首先.SYS」, 「flush.console」, 「幀」, 「getAllConnections」, 「getCConverterDescriptions」, 「getCConverterStatus」, 「geterrmessage」, 「get_ll_TOL」, 「get_ll_warn」, 「getLoadedDLLs」, 「getNumCConverters」, 「get_path」, 「get_Polypath」, 「get_PolypathRule」, 「get_ReplCRS_warn」, 「getRversion」, 「getTaskCallbackNames」, 「getwd」, 「graphics.off」, 「has_devel」,「 ,「is_false」,「is.R」,「is_true」,「Java」, 「l10n_info」,「last_plot」,「license」,「license」,「loadedNamespaces」, 「loaded_pa​​ckages」,「loadingNamespaceInfo」 ,「memory.profile」, 「newEmptyObject」,「.NotYetImplemented」,「.OptRequireMethods」, 「plot.new」,「progress_none」,「rc.status」,「Rdoc」,「recordPlot」, 「recover 「,」.rs.activateGraphicsDevice「,」.rs.createUUID「, 」.rs.defaultLibPathIsWriteable「,」.rs.defaultUserLibraryPath「, 」.rs.disableQuartz「,」.rs.helprIsActive「,」.rs。 iconvcommon「, 「.rs.initGraphicsDevice」, 「.rs.knitrChunkOptions」, 「.rs.listJsonRpcHandlers」, 「.rs.packages.initialize」, 「.rs.rpc.check_for_package_updates」, 「.rs.rpc.get_cran_mirrors」 , 「.rs.rpc.get_package_install_context」,「.rs.rpc.iconvlist」, 「.rs.rpc.init_default_user_library」,「.rs.rpc.list_objects」, 「.rs.rpc.list_packages」,「 .rs.rpc.remove_all_objects 「 」 .rs.setHelprLoadHook 「」 .rs.sweaveChunkOptions 「 」RStudioGD「, 」RStudio.version「,」 .rs.uniqueLibraryPaths 「 」 .rs.updatePackageEvents 「」 .rs.writeableLibraryPaths 「 」Rtangle「, 」R.Version「, 」RweaveLatex「, 」搜索「, 」搜索路徑中「, 」sessionData「, 」 .standard_regexps」, 「標準錯誤」, 「標準輸入」, 「標準輸出」 ,「sys.calls」, 「Sys.Date」, 「sys.frames」, 「Sys.getpid」, 「Sys.info」, 「Sys.localeconv」, 「sys.nframe」, 「sys.on.exit」,「sys.parents 」, 「sys.status」, 「系統」, 「Sys.time」, 「Sys.timezone」, 「TEMPDIR」, 「測試」, 「theme_get」, 「棄權」

+0

見'?是。原始「和搜索」原始「在https://github.com/hadley/devtools/wiki/functions – hadley 2013-02-14 22:52:49

+0

此外,你可以用'過濾器(emptyFormals,allFxns)'代替最後兩行' – hadley 2013-02-14 22:54:08

+0

最後,你可能也想看看https://github.com/hadley/pryr/blob/master/R/find-funs.r - 這不是解決同樣的問題,但它是相似的。 – hadley 2013-02-14 22:54:46