Displaying 20 results from an estimated 20000 matches similar to: "Odd behaviour of identical()"
2010 Jul 06
2
Odd subsetting behaviour
Hello. I've observed some odd behaviour. Most likely, it is already known and
explained somewhere, but I can't find an explanation anywhere, so I would
appreciate being pointed in the right direction.
The issue with the following code is self explanatory:
> mat <- matrix(c(c(1,1,1),c(2,2,2)),nrow=3)
> mat[,c(1:3%/%2)]
[,1] [,2]
[1,] 1 1
[2,] 1 1
[3,] 1 1
2012 Oct 08
1
Any better way of optimizing time for calculating distances in the mentioned scenario??
Dear All,
I'm dealing with a case, where 'manhattan' distance of each of 100
vectors is calculated from 10000 other vectors. For achieving this,
following 4 scenarios are tested:
1) scenario 1:
> x<-read.table("query.vec")
> v<-read.table("query.vec2")
> d<-matrix(nrow=nrow(v),ncol=nrow(x))
> for (i in 1:nrow(v)){
+ d[i,]<-
2013 Mar 08
2
Unexpected behaviour of apply()
Hello everyone,
Considering the following code sample :
----
indexes <- function(vec) {
vec <- which(vec==TRUE)
return(vec)
}
mat <- matrix(FALSE, nrow=10, ncol=10)
mat[1,3] <- mat[3,1] <- TRUE
----
Issuing apply(mat, 1, indexes) returns a 10-cell list, as expected.
Now if I do:
----
mat[1,3] <- mat[3,1] <- FALSE
apply(mat, 1, indexes)
----
I would expect a
2004 Dec 21
3
R code for var-cov matrix given variances and correlations
Dear list members,
Where can I find code for computing the p*p variance-covariance
matrix given a vector of p variances (ordered varA, varB, ...,
varp) and a vector of all possible correlations (ordered corAB,
corAC, ..., corp-1,p)?
I know that the covariance between 2 variables is equal to the
product of their correlation and their standard deviations:
corAB * varA^.5 * varB^.5
and so:
2009 Jul 03
2
Deos anyone know of a summary of conformability rules? along with a specific problem
The rules for conformability of objects required for various operators remain a mystery as do some related problems like the rules for recycling in creating arrays etc. Would someone be able to direct me to where such rules are stated?
In a related vein, there are all manner of operations that are readily coded in Gauss or in MATA that fail, often mysteriously, in R. Are there some
2024 Sep 17
1
findInterval
>>>>> Gabor Grothendieck
>>>>> on Mon, 16 Sep 2024 11:21:55 -0400 writes:
> Suppose we have `dat` shown below and we want to find the the `y` value
> corresponding to the last value in `x` equal to the corresponding component
> of `seek` and we wish to return an output the same length as `seek` using
> `findInterval` to perform the
2011 Apr 19
2
Simple question
I am trying to convert a string to a vector, and I'm stuck!
Suppose you have a string of numbers (string) that you want to convert to a
vector (vec). I am able to split the string turning it into a list by using
strsplit, but this makes a list, which I can't seem to access the way that
I'd like to (it becomes a character list of only one(?!?) element.)
2018 Nov 29
2
named arguments discouraged in `[.data.frame` and `[<-.data.frame`
Thanks Bill and Michael for taking the time to share your knowledge!
As a further background to my question, here are two examples that I forgot to include in my original post (reminded by Michael's answer). I swapped the i and j arguments in `[.data.frame` and `[<-.data.frame`. With warnings, but else without (?) problem. Using Bill's data:
`[.data.frame`(x = d, i = 1, j = 2)
# [1]
2002 Jan 04
1
plotting missing data patterns
I have one other problem and then I'll stop and get back to writing. I
want to plot a missing data matrix (the R matrix a la Little and Rubin)
to graphically depict where the missing data lie in the matrix. Some
statistical packages produce a graphical depiction of the missing data
patterns by plotting the matrix, color-coding the plot with contrasting
colors for either missing or
2018 Nov 28
3
named arguments discouraged in `[.data.frame` and `[<-.data.frame`
tl;dr:
Why are named arguments discouraged in `[.data.frame`, `[<-.data.frame` and `[[.data.frame`?
(because this question is of the kind 'why is R designed like this?', I though R-devel would be more appropriate than R-help)
#############################
Background:
Now and then students presents there fancy functions like this:
2012 Feb 11
2
Detect numerical series
Hello,
I am struggling with detecting successive digits in a numerical series
vector.
Here is an example:
vec <- c(1, 15, 26, 29, 30, 31, 37, 40, 41)
I want to be able to detect 29, 30, 31 and 40, 41.
Then, I would like to delete the successive digits from the vector.
1, 15, 26, 29, 37, 40
Cheers
--
View this message in context:
2013 Oct 11
3
matrix values linked to vector index
Hi,
In the example you showed:
m1<- matrix(0,length(vec),max(vec))
1*!upper.tri(m1)
#or
?m1[!upper.tri(m1)] <-? rep(rep(1,length(vec)),vec)
#But, in a case like below, perhaps:
vec1<- c(3,4,5)
?m2<- matrix(0,length(vec1),max(vec1))
?indx <- cbind(rep(seq_along(vec1),vec1),unlist(tapply(vec1,list(vec1),FUN=seq),use.names=FALSE))
m2[indx]<- 1
?m2
#???? [,1] [,2] [,3] [,4] [,5]
2011 Apr 20
2
get cells by the combination of their column and row names
Hi,
I have a (correlation) matrix and I want to select a subset of its cells depending on the combination of their column and row names.
This illustrates my problem: mtrx <- matrix(c(1,2,3,4,5,6,7,8,9), nrow=3, ncol=3, dimnames = list(c('c132','c432', 'c233'), c('r132','r233', 'r432')))> mtrx r132 r233 r432c132 1 4 7c432 2
2011 Feb 17
1
How to speed up a for() loop
Dear all,
Does anyone have any idea on how to speed up the for() loop below.
Currently it takes approximately 2 minutes and 30 seconds.
Because of the size of Nsim and N, simulating a multivariate normal
(instead of simulating Nsim times a vector of N normal distributions)
would require too much memory space.
Many thanks for your kind help,
Simona
N=3000
PD=runif(N,0,1)
cutoff.=qnorm(PD)
2010 Jan 12
4
Beginer data.frame
Hello,
I use R 2.10, and I am new in R (I used to use SAS and lately Stata), I am
using XP.
I have a data which has a data.frame format called x.df (read from a csv
file). I want to take from this data observations for which the variable
"Code" starts with an "R". I took all the Code and put them into a vector
vec<-grep("R[A-Z][A-Z]",x.df$Code,value=TRUE)
Then I
2011 Oct 29
4
R help with different combinations of vectors of different sizes
Hi,
I am trying to get different combinations of a vector of different size and
find their sum. For example, if I have a vector (i,j) where i and j can be
anything from 0 to 5, i get these combinations (0,0), (0,1), (1,0), (1,1),
(2,0), ...... (5,5) and find sum of these as 0, 1, 1, 2, ..... , 10. I used
outer functions to get this and it worked. What if I have a vector (i,j,k)
where all i, j ,
2010 May 17
2
retrieving last R output
Hello.
I ran a simulation that took a few days to complete, and want to analyze the
results, but have just realized that I (idiotically) did not assign the
output to a variable when I intitiated the simulation. Is there any way to
retrieve the last output produced by R so that these last few days were not
a waste?
Thank you very much.
--
View this message in context:
2010 Jan 02
2
help with for loop
Dear useRs,
I want to write a function that generates all the possible combinations of diff().
Example:
If my vector has length 5, I need the diff() until lag=4 ->
c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4))
If it has length 4, I need until lag=3 ->
c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3))
So, it must be until lag=(length(my.vec)-1).
2019 May 31
2
[patch] add sanity checks to quantile()
The attached patch adds some sanity checks to the "type" argument of
quantile(). Output from the following commands show the change of
behavior with the current patch:
vec <- 1:10
quantile(vec, type = c(1, 2))
quantile(vec, type = 10)
quantile(vec, type = "aaa")
quantile(vec, type = NA_real_)
quantile(vec, type = 4.3)
quantile(vec, type = -1)
Current behavior
2008 Dec 16
0
[LLVMdev] Another compiler shootout
On Tuesday 16 December 2008 01:03:36 Evan Cheng wrote:
> FYI. http://leonardo-m.livejournal.com/73732.html
>
> If anyone is motivated, please file bugs for the losing cases. Also,
> it might make sense to incorporate the tests into our nightly tester
> test suite.
FWIW, I just ported my ray tracer benchmark to C and found that llvm-gcc gives
much worse performance than gcc on x86