[R] Error in data.frame

John Wasige johnwasige at gmail.com
Wed Jan 21 18:54:36 CET 2015


Hi,

Kindly help me out on this error  from running SPI package. I am trying to
run SPI package with 30 years rainfall data but I get this error:

Error in data.frame(dates = dates, spi.plot[, 1:ncolumn]) :
  arguments imply differing number of rows: 30, 52559




#### script
require("raster")
require("rgdal")
require("ncdf")
require("spi")
setwd('D:/Lund2015/CRU1982_2011')

prec1 <- open.ncdf('D:/Lund2015/CRU1982_2011/
b8_cruts3.20_pre_19820101_20111231_1month_mean.nc')
###prec <-get.var.ncdf(prec1,"pre")
### get values
prec <-get.var.ncdf(prec1,"pre")
lons <-get.var.ncdf(prec1,"lon")
lats <-get.var.ncdf(prec1,"lat")
time <-get.var.ncdf(prec1,"time")
###plot(prec)

#dimensions
prec.dim <- dim(prec)
Nx <- prec.dim[1]
Ny <- prec.dim[2]
Nt <- prec.dim[3]


write.table(prec,file="spi1.txt", append = FALSE, na ="NA", dec = ".",
row.names = TRUE, col.names = TRUE)
spi(3,"spi1.txt",1982,2011)

####

 str(prec)

num [1:167, 1:146, 1:360]



Thanks for your help


John

	[[alternative HTML version deleted]]



More information about the R-help mailing list