Error in Source in R -
i use following source , error:
>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: ï»
since have use error , how can fix it? here code (the last line relevant command:
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 start date/time 1st entry in time series , make # character vector. start <- as.posixct(startdate) # transform character vector posixct object enddate <- as.character((end(z))) # set end date/time last entry in time series , make # character vector. end <- as.posixct(enddate) # transform character vector posixct object gridtime <- seq(from = start, = 3600, = end) # create sequence beginning start date/time 60 minute # interval ending @ end date/time ## source 1 ends ## source 2 begins timeframe <- data.frame(rep(na, length(gridtime))) # create 1 na column spaced out gridtime complement single # column of z timelength <- xts(timeframe, order.by = gridtime) # create xts time series object using timeframe , gridtime zdate <- merge(timelength, z) # merge z zoo object , timelength xts object ## source 2 ends lines <- as.data.frame(zdate) # data.frame 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 column order 3rd column followed 2nd , 1st # columns lines <- lines[, 3 := null] # remove 3rd column setnames(lines, 2, "diff") # change name of 2nd column diff lines <- setdf(lines) # return data.frame rowsinterps1 <- which(is.na(lines$diff == true)) # index of rows of lines have na (to interpolated) xi <- as.numeric(lines[which(is.na(lines$diff == true)), 1]) # date-times diff interpolated in numeric format interps1 <- na.interp1(as.numeric(lines$time), lines$diff, xi = xi, na.rm = false, maxgap = 3) # interpolated values gap sizes of 3 filled
the package updated that's reason code didn't work. wish people make points drop return them back. question ok.
Comments
Post a Comment