R执行报错:Error in `[<-.ts`(`*tmp*`,...only replacement of elements is allowed

原因:

pred$mean是Time-Series类型,rbind函数不支持。通过as.double将其转换成double类型即可。

修改前代码:

all_predata_time <- data.frame(pd=0.1,Row=1,preRow=0,pt=0.1,stasid=‘1‘,InitDate=‘1‘);
all_predata_time <- all_predata_time[-1,]

stasPowerPre_Time <- function(staid){
  testSrc<-......
  if(nrow(testSrc)>0)
  {
    maxDate <- max(testSrc$bizdate)
    tsd<- ts(testSrc$dp,start=c(2016,01,01),frequency=365)
    str(tsd)
    x <- ets(tsd)
    pred <- forecast(x,h=365)

    predata <- data.frame(pd = pred$mean)
    predata$Row <-as.integer(row.names(predata));
    predata$preRow <- predata$Row -1;
    predata$pt <- as.double(c(0));
    predata$stasid <- staid;
    predata$InitDate <- maxDate ;
    all_predata_time <<- rbind(all_predata_time,predata)
  }
}

  

修改后代码:

all_predata_time <- data.frame(pd=0.1,Row=1,preRow=0,pt=0.1,stasid=‘1‘,InitDate=‘1‘);
all_predata_time <- all_predata_time[-1,]

stasPowerPre_Time <- function(staid){
  testSrc<-......
  if(nrow(testSrc)>0)
  {
    maxDate <- max(testSrc$bizdate)
    tsd<- ts(testSrc$dp,start=c(2016,01,01),frequency=365)
    str(tsd)
    x <- ets(tsd)
    pred <- forecast(x,h=365)

    predata <- data.frame(pd = as.double(pred$mean))
    predata$Row <-as.integer(row.names(predata));
    predata$preRow <- predata$Row -1;
    predata$pt <- as.double(c(0));
    predata$stasid <- staid;
    predata$InitDate <- maxDate ;
    all_predata_time <<- rbind(all_predata_time,predata)
  }
}

  

参考:https://blog.csdn.net/wlt9037/article/details/74389807

原文地址:https://www.cnblogs.com/xianhan/p/9516147.html

时间: 2024-11-10 14:12:22

R执行报错:Error in `[<-.ts`(`*tmp*`,...only replacement of elements is allowed的相关文章

【mysql】 load local data infield 报错 ERROR 1148 (42000): The used command is not allowed with this MySQL version

mysql> load data local infile '/Users/flint/learn/mysql/pet' into table bx_pet; 执行报错 ERROR 1148 (42000): The used command is not allowed with this MySQL version 解决办法: 在连接数据库的时候使用 mysql --local-infile -uroot -p 连接即可 原文地址:https://www.cnblogs.com/china-

插入图片后R文件变红,报错“Error::app:mergeDebugResources&#39;. &gt; Some file crunching failed, see logs for detail”

本想做一个有爱的小东西,插入图片后发现原本之前运行成功的程序, 出现了报错“:app:mergeDebugResources'. > Some file crunching failed, see logs for detail” 一脸懵逼~~~这是什么鬼,在别人的回答和博客里找找解决办法. 不过对我好像不管用,找了好久才发现是图片的问题. 之前只是简单的在重命名的时候把图片改成“xx.png”,放在了app/src/main/res/drawable文件夹里(ps:目前每次我都是在复制图片再粘

长久不用的mysql报错ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/tmp/mysql.sock&#39; (2)

mac上安装过mysql: 然而,尝试连接时报错: $ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 尝试去查看mysql.socket文件,发现没有.. $ which mysql /usr/local/bin/mysql 然后试试重启mysql: $ mysql.server start

mac 安装mysql 报错“ERROR 2002 (HY000): Can not connect to local MySQL server through socket &#39;/tmp/mysql.sock&#39; (2)” 解决办法

首先安装 homebrew 再 brew install mysql 之后连接 mysql 无论是登录还是修改初始密码都会报如下的错误 ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2) 运行如下解决:参考 http://www.thinksaas.cn/group/topic/347978/ unset TMPDIR mysql_install_db --v

MySQL登录报错ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/tmp/mysql.sock&#39; (2)

[[email protected] mysql3307]# /opt/mysql3307/bin/mysql -upisp [email protected]123 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.so

java数据库执行迁移报错Error creating bean with name &#39;flywayInitializer&#39; defined in class path resource

报错原因 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocati

一看便知linux下mysql报错ERROR 1044: Access denied for user: &#39;@localhost&#39; to database &#39;mysql&#39;

错误信息:ERROR 1044: Access denied for user: '@localhost' to database 'mysql' linux下解决方案: mysql> use mysql ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql' mysql> exit Bye [[email protected] ~]# service mysqld stop如果该命令不

【MySQL笔记】mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法

step1:查看 1.1 Mysql命令行里输入"show engines:"查看innoddb数据引擎状态, 1.2 show variables "%_buffer%"里查看innodb_buffer_pool_size的数值,默认是8M(太小,需要改大一点!) step2:找配置文件,修改innodb_buffer_pool_size=64M 2.1 在linux里配置文件是my.cnf,windows里是my.ini(注:不是my-default.ini).

安装nghttp2 报错error: Libtool library used but &#39;LIBTOOL&#39; is undefined

nghttp2 报错error: Libtool library used but 'LIBTOOL' is undefined 如果重新安装libtool和autoconf升级到2.69后,还是报错, 则进行下面的操作: 1,查看aclocal的路径 aclocal --print-ac-dir 显示/usr/local/share/libtool/m4 ls看看里面没有m4文件. 则copy /usr/share/libtool/m4里面的m4文件到此目录下. 2,cd到nghtt2目录 执