當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


R語言 searchpath()用法及代碼示例


searchpath()R語言中的函數用於列出附加到R搜索路徑的包的完整路徑。

用法: searchpath()

參數:
這個函數沒有參數。

範例1:


# R program to get the full path
# of attached packages in R
  
# Calling searchpath() function
searchpath()

輸出:

[1] ".GlobalEnv"
[2] "C:/Program Files/R/R-2.15.2/library/stats"
[3] "C:/Program Files/R/R-2.15.2/library/graphics"
[4] "C:/Program Files/R/R-2.15.2/library/grDevices"
[5] "C:/Program Files/R/R-2.15.2/library/utils"
[6] "C:/Program Files/R/R-2.15.2/library/datasets"
[7] "C:/Program Files/R/R-2.15.2/library/methods"
[8] "Autoloads"
[9] "C:/PROGRA~1/R/R-215~1.2/library/base"

範例2:


# R program to get the full path
# of attached packages in R
  
# Attaching datasets to path
attach(BOD)
attach(airquality)
  
# Calling searchpath() function
searchpath()

輸出:

[1] ".GlobalEnv"
[2] "BOD"
[3] "airquality"
[4] "C:/Program Files/R/R-2.15.2/library/stats"
[5] "C:/Program Files/R/R-2.15.2/library/graphics"
[6] "C:/Program Files/R/R-2.15.2/library/grDevices"
[7] "C:/Program Files/R/R-2.15.2/library/utils"
[8] "C:/Program Files/R/R-2.15.2/library/datasets"
[9] "C:/Program Files/R/R-2.15.2/library/methods"
[10] "Autoloads"
[11] "C:/PROGRA~1/R/R-215~1.2/library/base"

相關用法


注:本文由純淨天空篩選整理自nidhi_biet大神的英文原創作品 Get the Full Path of all the Attached Packages in R Programming – searchpath() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。