[R-sig-Geo] Implementing a rolling window for stars object

Micha Silver t@v|b@r @end|ng |rom gm@||@com
Wed Oct 23 19:20:14 CEST 2019

On 23/10/2019 19:30, Andy Teucher wrote:
> Hi Micha,
> I can see two problems immediately with your code:
>  1. you are using a double-colon (yr::last_yr) - the double colon is 
> used for looking for an object in a package, so it is looking for 
> object ‘yrs’ in package ‘yr’, which obviously doesn’t make sense. Use 
> a single colon to create a range (like you did with 2:6)
> 2.  the object ‘last_yr’ is never defined, so even if you used a 
> single colon to define the range yr:last_yr, it would fail as it would 
> not be able to find object ‘last_yr’


I fixed those typos (corrected script attached) and I still get this error:

micha using tp480:R$ Rscript stars_window.R
Loading required package: abind
Loading required package: sf
Linking to GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0
Error in eval(rlang::expr(x[[i]][!!!args])) : object 'yr' not found
Calls: RunMK -> [ -> [.stars -> structure -> eval -> eval
Execution halted

> Cheers,
> Andy Teucher
>> On Oct 23, 2019, at 8:28 AM, Micha Silver <tsvibar using gmail.com 
>> <mailto:tsvibar using gmail.com>> wrote:
>> I am trying to run a function (mk.test to find MannKendall trends) 
>> using st_apply over a "rolling" window for a time series of rasters 
>> in a stars object.
>> When I use subscript notation to slice out the window dimension with 
>> a looping variable I get an error:
>> Error in loadNamespace(name) : there is no package called ‘yr’
>> Calls: [ ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
>> Execution halted
>> However If I replace the subscript with integers it works fine. (see 
>> attached)
>> What is the correct way to work this out?
>> Attached is a reprex with a small subset of my data. (The script 
>> starts with a long structure, code is at the end)
>> Thanks
>>   --
>> Micha Silver
>> Ben Gurion Univ.
>> Sde Boker, Remote Sensing Lab
>> cell: +972-523-665918
>> <stars_window.R>_______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org <mailto:R-sig-Geo using r-project.org>
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stars_window.R
Type: text/x-r-source
Size: 43807 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20191023/58025c4b/attachment.bin>

More information about the R-sig-Geo mailing list