Re: [R] error serialize (foreach)

2016-12-05 Thread Jon Skoien
Parallel processing usually includes quite a lot of overhead, which is expensive if the computation itself is quick. This is definitely an example where the function is too simple to take advantage of parallelization. Another thing is that your example has some errors, which makes the effect

Re: [R] The code itself disappears after starting to execute the for loop

2016-11-24 Thread Jon Skoien
I don't have a solution to this problem, but as I have also struggled with what I think is the same problem, I tried to find a small reproducible example. The problem seems indeed to be with the progress bar, which will clear the console after x iterations when the progress bar is called in a

Re: [R] about netcdf files

2016-07-27 Thread Jon Skoien
llowdimvar = TRUE, verbose = verbose) : > Variable not found > > > On Wed, Jul 27, 2016 at 1:10 AM, Jon Skoien > <jon.sko...@jrc.ec.europa.eu <mailto:jon.sko...@jrc.ec.europa.eu>> wrote: > > I think you get the error because you passed the obj

Re: [R] about netcdf files

2016-07-27 Thread Jon Skoien
ple_precip_daily.nc <http://sample_precip_daily.nc>') > pre1 > pre1_rd = ncvar_get(pre1, 'precipitation') > nc_close(pre1) > > Thanks for your help. > > On Tue, Jul 26, 2016 at 4:08 AM, Jon Skoien > <jon.sko...@jrc.ec.europa.eu <mailto:jon.sko...@jrc.ec.europa.eu>&

Re: [R] about netcdf files

2016-07-26 Thread Jon Skoien
You could try with the brick function from the raster package. bvar = brick(netcdfName) This uses the ncdf4 functions for opening and reading the netcdf, but makes it easier to extract data for each day: p1 = rasterToPoints(bvar[[1]]) and write p1 to csv. Best, Jon On 7/26/2016 6:54 AM,

[R] setTxtProgressBar clearing console (Windows RGui)

2015-09-16 Thread Jon Skoien
I have frequently noticed a strange effect when using the progress bar in a loop, that the console will sometimes be cleared. Whatever was printed before will then be inaccessible, which can be annoying when I want to check the progress and possible issues in a long script. It seems to be an

Re: [R] R parallel / foreach - aggregation of results

2015-07-31 Thread Jon Skoien
Martin, I think the main problem is that you are trying to assign your results to the result matrix inside the foreach loop. Parallel functions in R are generally not good at updating parts of matrices from the different workers in this way. Instead, using e.g. foreach, each loop of the

Re: [R] sampling rows with values never sampled before

2015-06-23 Thread Jon Skoien
If df is the data.frame with values and you want nn samples, then this is a slightly different approach: # example data.frame: df = data.frame(a1 = sample(1:20,50, replace = TRUE), a2 = sample(seq(0.1,10,length.out = 30),50, replace = TRUE),

Re: [R] How to download and unzip data in a loop

2015-02-05 Thread Jon Skoien
In addition to following Jim's suggestion, you should probably also use full.names = TRUE, otherwise you will try to open a connection to files in your current directory, not in tmpdir. Another thing is that the unzipped files appear irregular with respect to columns, so read.table might not

Re: [R] StackRaster problem

2014-08-26 Thread Jon Skoien
Did you attach the raster package with library(raster)? It seems the newest version of dismo does not depend on raster, so you will not be able to use raster-functions if you only attach dismo. This error message typically comes when R tries to use utils:::stack.default instead of the

Re: [R] ordinary kriging: the edges of the polygons are ignored

2014-08-21 Thread Jon Skoien
Hi Frederico, The kriging function seems to come from the kriging package (please give also the package next time you ask a question), which I dont know. I can therefore not tell you why it does not give you the correct result. But R has a huge number of packages which can krige, and

Re: [R] Copulas and spatial modeling

2014-07-30 Thread Jon Skoien
As a start you might look at the spcopula package from r-forge: install.packages(spcopula, repos = http://r-forge.r-project.org;) Spatial copulas can also be used for interpolation in the intamap package (on CRAN). You are likely to get more responses to questions about spatial modelling on

Re: [R] Raster manipulation in R

2011-12-01 Thread jon . skoien
Hi, Alternatively you could have a look at the function terrain in the raster package, it can calculate the slope for you using different algorithms, not sure if the one below is included though. For typical spatial requests like this, you could also use the mailing-list r-sig-geo.

Re: [R] Spatial Statistics using R

2011-11-17 Thread jon . skoien
Hi Ravi, You would probably get more answers to this if you posted to the list r-sig-geo. The following course was advertised a week ago and might match your needs: http://www.itc.nl/personal/rossiter/teach/degeostats.html You might also find the videos from this years' GEOSTAT course in

Re: [R] getting data associated with coordinates in a spatial data frame

2011-10-14 Thread jon . skoien
On 13-Oct-11 20:33, Sarah Goslee wrote: Hi, On Thu, Oct 13, 2011 at 2:05 PM, Bailey, Danielbai...@spu.edu wrote: Thank you Sarah. I tried your suggestion, and if I coerce it into a normal data.frame, that method works. But if you've already made the data into a SpatialPixelsDataFrame and run