Margarida Soares writes:
> Thanks for your reply on pls!
> I have tried to do a correlation plot but I get the following group of
> graphs. Any way of having only 1 plot?
> This is my script:
>
> corrplot(plsrcue1, comp = 1:4, radii = c(sqrt(1/2), 1), identify = FALSE,
> type = "p" )
"Correlatio
Hi
If some feature does not suit your intentions you can make your own. Especially
in this simple case.
myadd<-function(x,y) {
if(length(x)!=length(y)) {
n <- max(length(x), length(y))
length(x) <- n
length(y) <- n
x[is.na(x)]<-0
y[is.na(u)]<-0
}
x+y
}
> myadd(u,v)
[1] 11 22 33 4 5 6 7 8
Better get over it, because it isn't going to change. To avoid it, always work
with vectors of the same length.
This is a logical extension of the idea that a scalar adds to every element of
a vector.
--
Sent from my phone. Please excuse my brevity.
On December 12, 2017 9:41:06 PM PST, Maing
I'm a newbie for R lang. And I recently came across the "Recycling Rule" when
adding two vectors of unequal length.
I learned from this tutor [
http://www.r-tutor.com/r-introduction/vector/vector-arithmetics ] that:
""
If two vectors are of unequal length, the shorter one will be recycled
I believe ?filter will do what you want.
I used n = 100 instead of 1000:
ts <- 1:100
examp <- data.frame(ts=ts, stage=sin(ts))
examp <- within(examp, {
abv_1 <- filter(stage > 0.6, rep(1,7),sides =1)
abv_2 <- filter(stage > .85, rep(1,7), sides =1)
})
examp
I think this should be fairly
One way of doing it with data.table. It seems to scale up pretty well.
It takes 4 seconds on my computer with ts <- 1:1e6.
library(data.table)
per <- 7
elev1 <- 0.6
elev2 <- 0.85
ts <- 1:1000
examp <- data.table(ts=ts, stage=sin(ts))
examp[, `:=`(days_abv_0.6_in_last_7 = apply(do.call('cbind',
Try using stats::filter (not the unfortunately named dplyr::filter, which
is entirely different).
state>elev is a logical vector, but filter(), like most numerical
functions, treats TRUEs as 1s
and FALSEs as 0s.
E.g.,
> str( stats::filter( x=examp$stage>elev1, filter=rep(1,7),
method="convolution
The code below is a small reproducible example of a much larger problem.
While the script below works, it is really slow on the true dataset with
many more rows and columns. I'm hoping to get the same result to examp,
but with significant time savings.
The example below is setting up a data.frame
Hi All,
It seems to me that xyTable() gets thrown off by NAs:
x <- c(1, 1, 2, 2, 2, 3)
y <- c(1, 2, 1, 3, NA, 3)
table(x, y, useNA="always")
xyTable(x, y)
Is this intended behavior?
Best,
Wolfgang
__
R-help@r-project.org mailing list -- To UNSUBSCRI
9 matches
Mail list logo