uday
2012-Jan-24 08:32 UTC
[R] warning massage longer object length is not a multiple of shorter object length
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])))} but I got warning massage longer object length is not a multiple of shorter object length 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.
uday
2012-Jan-24 08:35 UTC
[R] warning massage longer object length is not a multiple of shorter object length
sorry there is typing error in codes the correct ones are nobs<-length(s_lat) for (i in 1:length(nobs)){lat_match<- which(abs(t_lat - s_lat =min(abs(t_lat - s_lat)))} -- View this message in context: http://r.789695.n4.nabble.com/warning-massage-longer-object-length-is-not-a-multiple-of-shorter-object-length-tp4323173p4323179.html Sent from the R help mailing list archive at Nabble.com.
Petr PIKAL
2012-Jan-24 09:27 UTC
[R] warning massage longer object length is not a multiple of shorter object length
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.5636.39> 40.22 44.05 > [37] 47.88 51.71 55.54 59.37 63.20 67.03 70.86 74.69 78.5282.35> 86.18 > > s_lat > [1] -29.5074 29.0861 25.1618 24.8664 20.4859 20.6189 20.740320.8525> 20.9576 > [10] 21.0575 21.1537 21.2477 21.3403 21.4330 21.5266 21.622421.7222> 21.8269 > [19] 20.1911 20.3238 20.4450 20.5570 20.6620 20.7617 20.857720.9516> 21.0443 > [28] 21.1368 21.2304 21.3263 21.4260 21.5308 21.6405 19.896320.0287> 20.1497 > [37] 20.2615 20.3663 20.4658 20.5618 20.6556 20.7481 20.840620.9342> 21.0301 > [46] 21.1299 21.2347 21.3445 19.6015 19.7336 19.8543 19.965920.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 ofshorter> object lengthSo 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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
uday
2012-Jan-24 09:47 UTC
[R] warning massage longer object length is not a multiple of shorter object length
Hi Thanks for reply, there was some mistakes in typo. I have already corrected it. this function gives us closest point ( R book reference). So I would like to find all observations on another grid spatially and temporally. the function is just for finding all closest observations. uday -- View this message in context: http://r.789695.n4.nabble.com/warning-massage-longer-object-length-is-not-a-multiple-of-shorter-object-length-tp4323173p4323318.html Sent from the R help mailing list archive at Nabble.com.