Displaying 20 results from an estimated 1000 matches similar to: "searching help for partial matches"
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
2009 Aug 05
7
why is 0 not an integer?
Why when I assign 0 to an element of an integer vector does the type change
to numeric?
Here is a particularly perplexing example:
> v <- 0:10
> v
[1] 0 1 2 3 4 5 6 7 8 9 10
> class(v)
[1] "integer"
> v[1] <- 0
> class(v)
[1] "numeric" #!!
>
--
View this message in context:
2009 Aug 05
7
why is 0 not an integer?
Why when I assign 0 to an element of an integer vector does the type change
to numeric?
Here is a particularly perplexing example:
> v <- 0:10
> v
[1] 0 1 2 3 4 5 6 7 8 9 10
> class(v)
[1] "integer"
> v[1] <- 0
> class(v)
[1] "numeric" #!!
>
--
View this message in context:
2024 Aug 18
2
allequal diff
Dear Ivan
Thanks a lot for this very nice example.
Is it true that all.equal just compares y values?
Based on this help here I think so and the value I got is the difference for the y-values.
https://www.statology.org/all-equal-function-r/
However, here I see x and y testing?
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/all.equal
I am actually interested in the x values
2009 Jul 08
2
print() to file?
I'd like to write some objects (eg arrays) to a log file. cat() flattens them
out. I'd like them formatted as in 'print' but print only writes to stdout.
Is there a simple way to achieve this result?
Thanks
--
View this message in context: http://www.nabble.com/print%28%29-to-file--tp24397445p24397445.html
Sent from the R help mailing list archive at Nabble.com.
2009 Aug 04
4
array slice notation?
Suppose I have an n-diml array A and I want to extract the first "row" -- ie
all elements A[1, ...]
Interactively if I know 'n' I can write A[1,,,,,] with (n-1) commas.
How do I do the same more generally, eg in a script?
(I can think of doing this by converting A to a vector then extracting the
approp elements then reshaping it to an array, but I wonder if there isn't a
2024 Aug 18
1
allequal diff
Ah...I see.
Perhaps, then, the maintainer should be contacted, as the desired
functionality seems similar to that provided in other all.equal
methods. I realize that this may often not elicit a (prompt) response.
-- Bert
On Sun, Aug 18, 2024 at 11:50?AM Ben Bolker <bbolker at gmail.com> wrote:
>
> The OP's original problem is that the all.equal method for raster
>
2024 Aug 18
2
allequal diff
"Is it true that all.equal just compares y values?"
The following may be a bit more than you may have wanted, but I hope
it is nevertheless useful.
The first place you should go to for questions like this is the Help
system, not here, i.e.
?all.equal
When you do this, you will find that all.equal() is a so-called S3
generic function, which, among other things, means that it works
2024 Aug 18
1
allequal diff
?? The OP's original problem is that the all.equal method for raster
objects (raster:::all.equal.raster), which is a wrapper around the
compareRaster() function, compares a bunch of different properties of
rasters (extent, resolution, values, etc.) and only returns a single
overall logical (TRUE/FALSE) value. OP wanted to see the magnitude of
the difference (as you could get for more
2009 Feb 13
3
R Help
Hi,
I have a list of numbers (classified as a list) that contains integer(0)
empty vectors. How do I convert those integer(0) into NAs? Thanks
[[alternative HTML version deleted]]
2004 Jul 30
2
mirroring in both directions with rsync
When operating in daemon mode, will rsync check to see which file is newer and decide which direction to transfer based on that?
Example,
We have 2 terminal servers, A and B. I want users to be able to work on either server and have their home directories on both stay in sync. If a user logs into server A and changes files, the server would know to transfer the file from A to B. If they log
2009 Jul 01
2
sorting question
I've asked about custom sorting before and it appears that -- in terms of a
user-defined order -- it can only be done either by defining a custom class
or using various tricks with "order"
Just wondering if anyone has a clever way to order "vintages" of the form
2002, 2003H1, 2003H2, 2004, 2005Q1, 2005Q2, etc
some have H1 or H2, some have Q1,Q2,Q3,Q4, some are just plain
2009 Jul 07
3
vectorizing a function
I'm sure I'm missing something obvious but I'm not seeing how to simply
"vectorize" a function of two or more variables.
Say I have
f <- function(x,y) if (x>0) y else -y
Now I have vectors x and y of equal length and I'd like to apply f
element-wise. I.e. conceptually
z <- f(x,y) where x, y, z are vectors of the same length
Some magic involving apply?
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 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
? Fri, 16 Aug 2024 11:32:58 +0200
<sibylle.stoeckli at gmx.ch> ?????:
> # 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)])
Let's consider a more tangible example:
# The
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
2006 Jan 13
2
find mean of a list of timeseries
Can someone please give me a clue how to 're'write this so I dont need
to use loops.
a<-ts(matrix(c(1,1,1,10,10,10,20,20,20),nrow=3),names=c('var1','var2','var3'))
b<-ts(matrix(c(2,2,2,11,11,11,21,21,21),nrow=3),names=c('var1','var2','var3'))