The answer depends on the encoding of the file containing the Chinese
characters and on the version of R (since you are using Windows). I copied
your subject line into Wordpad and and added some syntax to make a valid R
expression
s <- "永创 via R-help"
I then saved it with the type "Unicode Text
Hello,
If !!x obfuscates what the is doing, there's
M[, as.logical(x)] <- 0
Hope this helps,
Rui Barradas
Às 15:52 de 25/04/2022, Ivan Calandra escreveu:
Indeed, of course, my bad! I got confused by Bert's answer...
So my first suggestion to do M[, x == 1] was correct :)
--
Dr. Ivan Cala
Oh, I get it. The context was in choosing columns to set to 0 via a
**predicate**.
Sorry for the noise.
Bert
On Mon, Apr 25, 2022 at 7:39 AM Bert Gunter wrote:
>
> Yes, sorry. But it's with the logical cast it's still M[, c(FALSE,
> TRUE, FALSE)] which is M[, 2], and so I still don't get the
Yes, sorry. But it's with the logical cast it's still M[, c(FALSE,
TRUE, FALSE)] which is M[, 2], and so I still don't get the point.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom Count
Indeed, M[, x] <- 0 does the same, but only if x is 0's and 1's only,
right? I thought that it might not always be the case so I choose this
maybe superflous approach.
M[, 2] does the same of course in the example, but I was assuming that
the columns to change to zero are not known in advance
M[,x==1] is not the same as M[,x] :-)
However, M[,!!x] is the same as M[,x==1] and saves one character!
The point of this is "I can name that tune in ... " (as if that was not
obvious)
On Mon, Apr 25, 2022 at 5:30 PM Bert Gunter wrote:
> x == 1 is the same as M[, x] so your expression is the s
x == 1 is the same as M[, x] so your expression is the same as
M[, c(FALSE, TRUE, FALSE)] <- 0
which is the same as M[, 2] <- 0
So what is the point of all this, exactly?
Bert
On Mon, Apr 25, 2022 at 7:18 AM Ivan Calandra wrote:
>
> Hi Uwe,
>
> If I understood the problem completely and buildi
Hi Uwe,
If I understood the problem completely and building up on Tim's answer,
this is even easier:
M <- A <- matrix(1:9, ncol = 3)
x <- c(0, 1, 0)
M[, x == 1] <- 0
M
The original issue was with the way ifelse works. The explanation is in
the help page: "ifelse returns a value with the same
A <- matrix(1:9,ncol=3)
x <- c(0,1,0)
M <- matrix(ncol=3,nrow=3)
M<-A
for(i in 1:3) {
if(x[i]){
M[,i] <-0
}
}
}
M
The outcome you want is to set all of the middle column values to zero. So I
used x as a logical in an if test and when true everything in that column is
set to zero.
Y
Hello,
Here is the link to the archived versions of package measurements [1].
But the edit to that answer has another solution, with sp::char2dms and
you are loading package sp.
[1] https://cran.hafro.is/src/contrib/Archive/measurements/
Hope this helps,
Rui Barradas
Às 10:57 de 25/04/2022
Hello,
See if this StackOverflow.com post [1] solves your problem.
Also, examples should be minimal, you don't need all those packages to
solve this problem.
[1] https://stackoverflow.com/a/69485865/8245406
Hope this helps,
Rui Barradas
Às 21:43 de 24/04/2022, Nicolas Degallier escreveu
В Sun, 24 Apr 2022 17:05:55 +0200
Uwe Freier пишет:
> ifelse(x[i] == 0, A[,i], 0)
Hint: what does ifelse return instead of a vector of length nrow(A)?
Since you're checking conditions of length 1, you can safely use `if
(x[i] == 0) A[,i] else 0` here, or you can transform the `x` vector
into a
Hello,
sorry for the newbie question but I can't find out where I'm wrong.
A <- matrix(1:9,ncol=3)
x <- c(0,1,0)
M <- matrix(ncol=3,nrow=3)
for(i in 1:3) {
M[,i] <- ifelse(x[i] == 0, A[,i], 0)
}
expected:
M
[,1] [,2] [,3]
[1,]107
[2,]208
[3,]309
bu
Dear R Users,
I am using a 'simple' script to draw maps with points.
It runs fine with the following libraries:
library(sp)
library(maptools)
library(maps)
library(mapdata)
library(RColorBrewer)
library(MASS)
library(rgeos)
library(GISTools)
Until now, to prepare the input data, I have used manua
14 matches
Mail list logo