similar to: How R converts data between objects

Displaying 20 results from an estimated 4000 matches similar to: "How R converts data between objects"

2011 Apr 09
1
For->lapply->parallel apply
Dear all, I would like to ask your help understand the subsequent steps for making my program faster. The following code: Gauslist<-array(data=NA,dim=c(dimx,dimy,dimz)) for (i in c(1:dimz)){ print(sprintf('Creating the %d map',i)); Gauslist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } creates 100 GaussMaps (each
2011 Apr 22
1
ggplot
Hello everyone, I am using ggplot to plot but I am getting the following error which I do not understand Error: geom_text requires the following missing aesthetics: label My code is dimx<-256 library(ggplot2) dev.new() xandy<-expand.grid(seq(1:dimx),seq(1:dimy)) xx<-data.frame(xandy[[1]],xandy[[2]],Powermap=Powermap) subsetxx<-subset(xx, xx$Powermap>threshold)
2011 Apr 11
1
Comparing execution times
Dear all, In my 'simple' computer I was running some experiments to help me understand how faster a multicore lapply will be. I thought it might be interesting for some people to look at the results. Even though are not accurate, still might be a good indicator how much improvement there can be. A.Case. The classic: for 1:100 for (i in c(1:dimz)){ print(sprintf('Creating the %d
2011 May 30
0
2D random walk with traps convert C++ code to R code
Hello, I have a C++ code for 2D random walks with traps and I want to convert it in a R code with its syntaxs, can anyone help??????? It's easy for me to adapt the body but I want help with the beginig (variable declaration) and th end exporting the output to a file ( like write.table() or sink() ) Thank you... #include <iostream> #include <math.h>#include
2011 Mar 30
4
a for loop to lapply
Dear all, I am trying to learn lapply. I would like, as a test case, to try the lapply alternative for the Shadowlist<-array(data=NA,dim=c(dimx,dimy,dimmaps)) for (i in c(1:dimx)){ Shadowlist[,,i]<-i } ---so I wrote the following--- returni <-function(i,ShadowMatrix) {ShadowMatrix<-i} lapply(seq(1:dimx),Shadowlist[,,seq(1:dimx)],returni) So far I do not get same results
2011 Apr 27
6
Assignments inside lapply
Dear all I would like to ask you if an assignment can be done inside a lapply statement. For example I would like to covert a double nested for loop for (i in c(1:dimx)){ for (j in c(1:dimy)){ Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f) } } to something like that: ij<-expand.grid(i=seq(1:dimx),j=(1:dimy)) unlist(lapply(1:nrow(ij),function(rowId) { return
2009 Aug 04
0
Writing a NetCDF file in R
Dear all, I am attempting to convert 10 NetCDF files into a single NetCDF file, due to the data input requirements of a model I hope to use. I am using the ncdf package, version 1.6. The data are global-scale water values, on a monthly basis for 10 years (ie. 120 months of data in total; at present the data are separated by year, with 12 months of data in each file - mrunoff_1986 through to
2009 Aug 05
0
ncdf package problem - put.var.ncdf
Dear all, I am attempting to convert 10 NetCDF files into a single NetCDF file, due to the data input requirements of a model I hope to use. I am using the ncdf package, version 1.6. The data are global-scale water values, on a monthly basis for 10 years (ie. 120 months of data in total; at present the data are separated by year, with 12 months of data in each file - mrunoff_1986 through to
2007 May 21
1
size limit in R?
Hi, Please see the email exchanges below. I am having trouble generating output that is large enough for our needs, specifically when using the GaussRF function. However, when I wrote Dr. Schlather (the author of the GaussRF function), he indicated that there is also a limit imposed by R itself. Is this something that we can overcome? Thank you very much for any assistance you may provde.
2011 Apr 11
1
Mclapply and print statement
Dear all. I am using the mclapply function to split my code to the many cores my system has. It seems that is working fine. This is the parallel version of lcapply. The only problem that I seem to have is that the printf cannot print messages. The ideal to me is to have fro my function an output of the form Shadowlist<-mclapply(1:dimz, function(i) { print(sprintf('Creating the
2010 Nov 05
0
NaN, ncdf
Dear All, Can anyone please let me know how exactly ncdf deals with NaN. I am trying to pass in a vector of data that has some NaN in it, into a variable in NetCDF. dimX <- dim.def.ncdf("X","count",(1:6)) dimY <- dim.def.ncdf("Y","count",(1:3)) var1 <-
1998 May 29
0
aov design questions
R developers, I have a first attempt to make an aov function. Eventually I want to build in Error() structure, but first I am trying to get this presentable for balanced data with only a single stratum, just using residual error. I am following R. M. Heiberger's Computation for the Analysis of Designed Experiments, Wiley (1989) I a using a wrapper (aov.bal) to call the
2010 Jul 28
2
Beginner stucked with raster + geoR package.
Hello everyone. I am trying to build up understanding in R by trying to develop just some simple scenarios. I would like to explain you what I am trying to do and what I did so far. I would like to put inside a RasterLayer (raster package) a Gaussian field (for given covariance) using grf function (geoR package) 1. First I created a Raster Layer object r <- raster() # Default values are
2012 Feb 10
0
range and anisotropy with RandomFields
Hello, I am presently trying to get a feel for the various packages out there that allow me to both analyze and simulate random fields. The package RandomFields is nice, but there are still a few aspects of its implementation that are confusing to me and I was hoping someone could help clarify things for me. It could also be that my questions reflect a lack of knowledge pertaining to random
2024 Aug 16
2
allequal diff
Many thanks Ivan Use is.na() on getValues() outputs, combine the two masks using the | operator to get a mask of values that are missing in either raster, then negate the mask to choose the non-missing values: all.equal(getValues(r1)[!mask], getValues(r2)[!mask]) --> what do you mean by use is.na() in getValues(). So I need to call getValues a second time? I suppose you mean to first
2024 Aug 16
1
allequal diff
? Fri, 16 Aug 2024 10:35:35 +0200 <sibylle.stoeckli at gmx.ch> ?????: > what do you mean by use is.na() in getValues(). So I need to call > getValues a second time? Not necessarily, but it's one of the options. I was thinking along the lines of: values1 <- getValues(r1) mask1 <- is.na(values1) # Do the same for r2 # Combine the masks all.equal(values1[!combined_mask],
2024 Aug 16
1
allequal diff
Dear Ben Many thanks. I see that a second challenge are NA values. Is it possible to consider na.rm=TRUE? > r2_resampled <- resample(r2, r1) > compareRaster(r1, r2_resampled) [1] TRUE > > all.equal(getValues(r1), getValues(r2_resampled), tolerance = 0) [1] "'is.NA' value mismatch: 9544032 in current 66532795 in target" Kind regards Sibylle
2024 Aug 16
1
allequal diff
Cool thanks # values and mask r1 r1 <- getValues(r1) mask1 <- is.na(r1) # Do the same for r2 r2 <- getValues(r2_resampled) mask2 <- is.na(r2) # Combine the masks all.equal(r1[!(mask1 & mask2)], r2[!(mask1 & mask2)]) output > all.equal(r1[!(mask1 & mask2)], r2[!(mask1 & mask2)]) [1] "'is.NA' value mismatch: 389 in current 56989152 in target"
2024 Aug 16
1
allequal diff
? Fri, 16 Aug 2024 07:19:38 +0200 SIBYLLE ST?CKLI via R-help <r-help at r-project.org> ?????: > Is it possible to consider na.rm=TRUE? > > all.equal(getValues(r1), getValues(r2_resampled), tolerance = 0) > > [1] "'is.NA' value mismatch: 9544032 in current 66532795 in target" Use is.na() on getValues() outputs, combine the two masks using the | operator
2024 Aug 15
1
allequal diff
Digging into the code for raster::compareRaster(): library(raster) r <- raster(ncol=3, nrow=3) values(r) <- 1:ncell(r) r2 <- r values(r2) <- c(1:8,10) all.equal(getValues(r), getValues(r2), tolerance = 0) [1] "Mean relative difference: 0.1111111" compareRaster has fancier machinery internally for doing the comparison for large rasters a block at a time if everything