Re: [R] help with grouping data and calculating the means

2018-11-15 Thread Anthoni, Peter (IMK)
Hi Sasa, Those latitude look equidistant with a separation of 0.05. I guess you want to calculate the zonal mean along the latitude, right? #estimate the lower and upper latitude for the cut lat.dist=0.05 #equidistant spacing along latitude lat.min=min(df$LAT,na.rm=T)-lat.dist/2 lat.max=max(df$LA

Re: [R] help with grouping data and calculating the means

2018-11-15 Thread Bert Gunter
On further thought -- and subject to my prior interpretation -- I think a foolproof way of truncating to 4 decimal digits is to treat them as character strings rather than numerics and use regex operations: > with(df,tapply(TK.QUADRANT, > sub("(\\.[[:digit:]]{4}).*","\\1",as.character(LAT)),mean)

Re: [R] help with grouping data and calculating the means

2018-11-15 Thread Bert Gunter
On Thu, Nov 15, 2018 at 10:40 AM Boris Steipe wrote: > > Use round() with the appropriate "digits" argument. Then use unique() to > define your groups. No. > round(c(.124,.126),2) [1] 0.12 0.13 As I understand it, the OP said he wanted the last decimal to be ignored. The OP also did not speci

Re: [R] help with grouping data and calculating the means

2018-11-15 Thread Boris Steipe
Use round() with the appropriate "digits" argument. Then use unique() to define your groups. HTH, B. > On 2018-11-15, at 11:48, sasa kosanic wrote: > > Dear All, > > I would very much appreciate the help with following: > I need to calculate the mean of different lat/long points that shoul