【问题标题】:read.table in R startup scriptR 启动脚本中的 read.table
【发布时间】:2011-11-12 10:57:45
【问题描述】:

.Rprofile(基于these2 帖子。我不得不删除.First<-function(){ }。):

cat(rep("\n", 50))
if(file.exists("~/algae/analysisTxt.r")){
    source("~/algae/analysisTxt.r")
    cat("algae was loaded")
}

analysisTxt.r

algae <- read.table('http://www.liaad.up.pt/~ltorgo/DataMiningWithR/DataSets/Analysis.txt',
         header=F,
         dec='.',
         col.names=c('season','size','speed','mxPH','mnO2','Cl','NO3','NH4','oPO4','PO4','Chla','a1','a2','a3','a4','a5','a6','a7'),
         na.strings=c('XXXXXXX'))

运行时,清屏后出现此错误

Error in eval.with.vis(expr, envir, enclos) : 
  could not find function "read.table"

我该怎么办?

【问题讨论】:

  • 在你的启动中加载一个数据文件是一件很奇怪的事情。

标签: r startup


【解决方案1】:

read.tableutils包中的一个函数,那么在read.table的调用之前在.RprofileanalysisTxt.r中调用library(utils)怎么样?

【讨论】:

  • 它会起作用的。我不知道哪个更好。可能任何一种方式都可以。
  • utils:::read.table 我猜是首选。使用library(utils) 将加载包,然后它可能会在稍后的启动中再次发生。我见过的大多数 R 示例都使用 ::: 表示法。
猜你喜欢
  • 2016-08-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-17
  • 2012-02-20
  • 2021-12-14
  • 2019-04-14
  • 1970-01-01
相关资源
最近更新 更多