[R] warning massage longer object length is not a multiple of shorter object length

Petr PIKAL petr.pikal at precheza.cz
Tue Jan 24 10:27:17 CET 2012


Hi

> 
> Dear All, 
> 
> I have data set which includes details of locations e.g latitude, 
longitude
> , time. 
> I would like to compare two different data sets ( sampling in space and
> time).
> 
> the e.g data sets are as follows 
> 
> t_lat
>  [1] -90.00 -86.17 -82.34 -78.51 -74.68 -70.85 -67.02 -63.19 -59.36 
-55.53
> -51.70 -47.87
> [13] -44.04 -40.21 -36.38 -32.55 -28.72 -24.89 -21.06 -17.23 -13.40 
-9.57 
> -5.74  -1.91
> [25]   1.92   5.75   9.58  13.41  17.24  21.07  24.90  28.73  32.56 
36.39 
> 40.22  44.05
> [37]  47.88  51.71  55.54  59.37  63.20  67.03  70.86  74.69  78.52 
82.35 
> 86.18
> 
> s_lat
>  [1] -29.5074  29.0861  25.1618  24.8664  20.4859  20.6189  20.7403 
20.8525 
> 20.9576
> [10]  21.0575  21.1537  21.2477  21.3403  21.4330  21.5266  21.6224 
21.7222 
> 21.8269
> [19]  20.1911  20.3238  20.4450  20.5570  20.6620  20.7617  20.8577 
20.9516 
> 21.0443
> [28]  21.1368  21.2304  21.3263  21.4260  21.5308  21.6405  19.8963 
20.0287 
> 20.1497
> [37]  20.2615  20.3663  20.4658  20.5618  20.6556  20.7481  20.8406 
20.9342 
> 21.0301
> [46]  21.1299  21.2347  21.3445  19.6015  19.7336  19.8543  19.9659 
20.0705 
> 20.1700
> [55]  20.2658  20.3595  20.4520  20.5444  20.6380  20.7339
> 
> 
> I have tried 
> nobs<-length(s_lat)
> for (i in 1:length(nobs)){lat_match<-
> which(abs(sci_lat-tm3_lat[30])==min(abs(sci_lat-tm3_lat[30])))}

What is tm3_lat and sci_lat?

== is not recommendable for comparing floating point numbers

What is the result
abs(sci_lat-tm3_lat[30])
min(abs(sci_lat-tm3_lat[30])

You probably try to do something intuitively without any knowledge of R 
objects and functions which will give you much frustration.
Before putting your objects and code into the for cycle I would recommend 
you to try manually the results for some given i.

Regards
Petr

> 
> but I got warning massage longer object length is not a multiple of 
shorter
> object length

So one of objects you produced has different length from the other one 
used in your calculations and is according to rules recycled.

Regards
Petr

> 
> So could somebody please tell me how to solve  this kind of  problem ?
> 
> Thank you 
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/warning-
> massage-longer-object-length-is-not-a-multiple-of-shorter-object-length-
> tp4323173p4323173.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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