R中的源错误

时间:2016-01-16 20:35:45

标签: r

我使用以下来源并收到错误:

>source("raw.githubusercontent.com/iembry-USGS/ie2misc/master/R/…)
Error in source("raw.githubusercontent.com/iembry-USGS/ie2misc/master/R/…) : raw.githubusercontent.com/iembry-USGS/ie2misc/master/R/…: unexpected input 1: ï»

因为我必须使用什么是错误以及如何解决它? 这是我的代码(最后一行是相关命令:

library(zoo)
library (xts)
library(data.table)

source("https://raw.githubusercontent.com/iembry-USGS/ie2misc/master/R/na.interp1.R")

Lines <- "D1,Diff
1,20/11/2014 16:00,0.01
2,20/11/2014 17:00,0.02
3,20/11/2014 19:00,0.03
4,21/11/2014 16:00,0.04
5,21/11/2014 17:00,0.06 
6,21/11/2014 20:00,0.10"
z <- read.zoo(text = Lines, tz = "", format = "%d/%m/%Y %H:%M", sep = ",")


## Source 1 begins
startdate <- as.character((start(z)))
# set the start date/time as the 1st entry in the time series and make
# this a character vector.

start <- as.POSIXct(startdate)
# transform the character vector to a POSIXct object

enddate <- as.character((end(z)))
# set the end date/time as the last entry in the time series and make   
# this a character vector.

end <- as.POSIXct(enddate)
# transform the character vector to a POSIXct object

gridtime <- seq(from = start, by = 3600, to = end)
# create a sequence beginning with the start date/time with a 60 minute 
# interval ending at the end date/time
## Source 1 ends

## Source 2 begins
timeframe <- data.frame(rep(NA, length(gridtime)))
# create 1 NA column spaced out by the gridtime to complement the single 
# column of z

timelength <- xts(timeframe, order.by = gridtime)
# create a xts time series object using timeframe and gridtime

zDate <- merge(timelength, z)
# merge the z zoo object and the timelength xts object  
## Source 2 ends

Lines <- as.data.frame(zDate)
# to data.frame from zoo

Lines[, "D1"] <- rownames(Lines)
# create column named D1

Lines <- setDT(Lines)
# create data.table out of data.frame

setcolorder(Lines, c(3, 2, 1))
# set the column order as the 3rd column followed by the 2nd and 1st 
# columns

Lines <- Lines[, 3 := NULL]
# remove the 3rd column

setnames(Lines, 2, "diff")
# change the name of the 2nd column to diff

Lines <- setDF(Lines)
# return to data.frame

rowsinterps1 <- which(is.na(Lines$diff == TRUE))
# index of rows of Lines that have NA (to be interpolated)

xi <- as.numeric(Lines[which(is.na(Lines$diff == TRUE)), 1])
# the Date-Times for diff to be interpolated in numeric format

interps1 <- na.interp1(as.numeric(Lines$Time), Lines$diff, xi = xi, na.rm = FALSE, maxgap = 3)
# the interpolated values where only gap sizes of 3 are filled

1 个答案:

答案 0 :(得分:0)

包已更新,这是代码无效的原因。 我希望那些让分数下降的人会把他们归还。问题还可以。