[R] Error in data.frame

MacQueen, Don macqueen1 at llnl.gov
Thu Jan 22 00:35:04 CET 2015


Since neither of the objects named in the error message, dates and
spi.plot, show up in your script, it's pretty much impossible to guess.

You will probably find that if you do
   length(dates)
   nrow(spi.plot)
you will get different numbers. Perhaps 30 for one of them and 52559 for
the other. (This assumes that "dates" is a vector, which can't be verified
from what you provided.) Try looking at
  str(dates)
  str(spi.plot)

It would help if you could do as suggested at the bottom of every message
on R-help:

"PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code."


Also, try not to send html formatted email.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 1/21/15, 9:54 AM, "John Wasige" <johnwasige at gmail.com> wrote:

>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]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list