help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

help

Marco Antonio Pérez
 I am trying to write a function to make a matrix of precipitation with
this secuencie;
######## PRIMER PERIODO
cordex1 <-
nc_open("pr_CAM-44i_ICHEC-EC-EARTH_rcp45_r12i1p1_SMHI-RCA4_v1_mon_200601-201012.nc")
fullmon1<-ncvar_get(cordex1,"pr")
lat<-ncvar_get(cordex1,"lat", start=c(35.5),count=c(20))
lon <-ncvar_get(cordex1,"lon", start=c(125),count=c(21.5))
t <- ncvar_get(cordex1,"time")
nlon <- dim(lon)
nlat <- dim(lat)
nt <- dim(t)
fulldatav <- as.vector(fullmon1)
fulldata <- matrix(fulldatav, nrow=nlon*nlat, ncol=nt)
lonlat <- expand.grid(lon,lat)
df_cordex1<- data.frame(lonlat,fulldata)

but with the expresion  fulldata <- matrix(fulldatav, nrow=nlon*nlat,
ncol=nt) this error appears
Warning message:
In matrix(fulldatav, nrow = nlon * nlat, ncol = nt) :
  data length [1378620] is not a sub-multiple or multiple of the number of
rows [420]

Somebody help me!!!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: help

R help mailing list-2
Marco,

The error message indicates that nlon*nlat is 420 and that 1378620/420 has a remainder. For the matrix to form, all rows have to be complete.

I am guessing you have at least one value incorrect among nlon, nlat, t or the length of fulldatav.

Mark
R. Mark Sharp, Ph.D.
Data Scientist and Biomedical Statistical Consultant
7526 Meadow Green St.
San Antonio, TX 78251
mobile: 210-218-2868
[hidden email]











> On Aug 10, 2018, at 10:00 AM, Marco Antonio Pérez <[hidden email]> wrote:
>
> I am trying to write a function to make a matrix of precipitation with
> this secuencie;
> ######## PRIMER PERIODO
> cordex1 <-
> nc_open("pr_CAM-44i_ICHEC-EC-EARTH_rcp45_r12i1p1_SMHI-RCA4_v1_mon_200601-201012.nc")
> fullmon1<-ncvar_get(cordex1,"pr")
> lat<-ncvar_get(cordex1,"lat", start=c(35.5),count=c(20))
> lon <-ncvar_get(cordex1,"lon", start=c(125),count=c(21.5))
> t <- ncvar_get(cordex1,"time")
> nlon <- dim(lon)
> nlat <- dim(lat)
> nt <- dim(t)
> fulldatav <- as.vector(fullmon1)
> fulldata <- matrix(fulldatav, nrow=nlon*nlat, ncol=nt)
> lonlat <- expand.grid(lon,lat)
> df_cordex1<- data.frame(lonlat,fulldata)
>
> but with the expresion  fulldata <- matrix(fulldatav, nrow=nlon*nlat,
> ncol=nt) this error appears
> Warning message:
> In matrix(fulldatav, nrow = nlon * nlat, ncol = nt) :
>  data length [1378620] is not a sub-multiple or multiple of the number of
> rows [420]
>
> Somebody help me!!!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.