Displaying 20 results from an estimated 600 matches similar to: "nesting multiple for loops"
2001 Nov 01
1
Erratic behaviour of sammon()
I'm not sure this list is the right place for this thing.
I noticed some erratic behaviour in sammon(). Running sammon on
two nearly identical sets of data results in very different
results. Below is an example. I create an initial configuration
with cmdscale() and store it into 'vec1'. I write this to file,
and read it back in again to 'vec2'. According to cor() on the
three
2007 Aug 23
0
indexing and regression testing
Dear all,
It was a pleasure to meet you at Iowa State University. Two days ago I submitted two experimental packages to CRAN (hope it will be there soon):
rindex: quick indexing of large objects (currently only character, see ?index)
regtest: some first support for automated regression testing (heavily used in \dontshow{} section of ?index)
With rindex you can for example
i <-
2024 Jun 16
1
slowness when I use a list comprehension
This can be vectorized. Try
ix <- seq_along(vec2)
S_diff2 <- sapply(seq_len(N1-(N2-1)*ratio_sampling), \(j)
sum((vec1[(ix-1)*ratio_sampling+j] - vec2[ix])**2))
On Sun, Jun 16, 2024 at 11:27?AM Laurent Rhelp <laurentRHelp at free.fr> wrote:
>
> Dear RHelp-list,
>
> I try to use the package comprehenr to replace a for loop by a list
> comprehension.
>
> I
2009 Jul 27
1
how to use do.call together with cbind and get inside a function
Dear R-helpers:
I have a question related to using do.call to call cbind and get.
#the following works
vec1 <- c(1,2)
vec2 <- c(3,4)
ColNameVec <- c('vec1','vec2')
mat <- do.call("cbind",lapply(ColNameVec,get))
mat
#put code above into a function then it does not work
#before doing so, first remove vec1 and vec2 from global environment
rm(vec1,vec2)
test
2008 Dec 30
2
[LLVMdev] Folding vector instructions
Hello.
Sorry I am not sure this question should go to llvm or mesa3d-dev mailing
list, so I post it to both.
I am writing a llvm backend for a modern graphics processor which has a ISA
very similar to that of Direct 3D.
I am reading the code in Gallium-3D driver in a mesa3d branch, which
converts the shader programs (TGSI tokens) to LLVM IR.
For the shader instruction also found in LLVM IR,
2011 Jun 03
2
Arules: R Crashes when running eclat with tidLists=TRUE
Hello,
I'm using the eclat function of the arules package (1.0-6) for the
identification of frequent itemsets. I need the tidLists, but if I set
in the function tidLists=TRUE R crashes (Windows XP Professional SP3,
32 bit, R version 2.12.1 (2010-12-16), reproducible on two different
computers) with two different error messages or non at all. Minimum
examples are:
library(arules)
2024 Jun 16
1
slowness when I use a list comprehension
I would be more strong on this advice: learn to think in R, rather than thinking in Python, when programming in R. R has atomic vectors... Python does not (until you import a package that implements them). I find that while it is possible to import R thinking into Python, Python programmers seem to object for stylistic reasons even though such thinking speeds up Python also.
A key step in that
2008 May 12
1
lexicographic comparison of two vectors
Is there any built-in way to lexicographically compare two vectors of
the same length in R? The textbook algorithm could be coded as follows:
lex.cmp <- function (vec1,vec2) {
for (j in 1:length(vec1)) {
if (vec1[j] < vec2[j]) { return(-1) }
if (vec1[j] > vec2[j]) { return(1) }
}
return(0)
}
Thanks,
Gabriel
2004 May 25
1
cor and missing values. Bug?
There seems to be an issue in computing rank correlations with missing
values present. I think this comes from the way rank() function works but
I am not sure how to go about this. Rank function places missing values at
the end by default thus skewing the rank relationship between two vectors:
Example:
R : Copyright 2003, The R Foundation for Statistical Computing
Version 1.8.1 (2003-11-21),
2024 Jun 16
2
slowness when I use a list comprehension
Dear RHelp-list,
?? I try to use the package comprehenr to replace a for loop by a list
comprehension.
?I wrote the code but I certainly miss something because it is very
slower compared to the for loops. May you please explain to me why the
list comprehension is slower in my case.
Here is my example. I do the calculation of the square difference
between the values of two vectors vec1 and
2012 Aug 24
6
updating elements of a vector sequentially - is there a faster way?
I would like to know whether there is a faster way to do the below
operation (updating vec1).
My objective is to update the elements of a vector (vec1), where a
particular element i is dependent on the previous one. I need to do this on
vectors that are 1 million or longer and need to repeat that process
several hundred times. The for loop works but is slow. If there is a faster
way, please let
2024 Jun 16
1
slowness when I use a list comprehension
I fully agree with Jeff that the best way to use ANY language is to evaluate
the language in terms of not just the capabilities it offers but also the
philosophy behind what it was created for and how people do things and just
grok it and use it mostly in the way intended. I do that with all the
languages I learn, whether for computers or humans.
Bringing in something you like from another
2010 Jul 12
2
findInterval and data resolution
Hello Wise Ones...
I need a clever way around a problem with findInterval. Consider:
vec1 <- 1:10
vec2 <- seq(1, 10, by = 0.1)
x1 <- c(2:3)
a1 <- findInterval(x1, vec1); a1 # example 1
a2 <- findInterval(x1, vec2); a2 # example 2
In the problem I'm working on, vec* may be either integer or numeric, like
vec1 and vec2. I need to remove one or more sections of this vector;
2024 Jun 16
1
slowness when I use a list comprehension
Laurent,
Thank you for introducing me to a package I did not know existed as I use features like list comprehension in python all the time and could see using it in R now that I know it is available.
As to why you see your example as slow, I see you used a fairly complex and nested expression and wonder if it was a better way to go. As you are dealing with an interpreter doing delayed
2013 Mar 22
2
A question on function return
Hello again,
Let say I have following user defined function:
fn <- function(x, y) {
Vec1 <- letters[1:6]
Vec2 <- 1:5
return(list(ifelse(x > 0, Vec1, NA), ifelse(y > 0, Vec2, NA)))
}
Now I have following calculation:
> fn(-3, -3)
[[1]]
[1] NA
[[2]]
[1] NA
> fn(3, -3)
[[1]]
[1] "a"
[[2]]
[1] NA
Here I can not understand why in the second case, I get
2013 Apr 18
1
vectors with equal values
Hi,
Try:
?vec1<-c(1,1,1,1,1,1,1,1,1)
if(all(vec1==1)) "xxxxxxxxx" else? "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
?vec2<-c(rep(1,4),2)
?if(all(vec2==1)) "xxxxxxxxx" else? "yyyyyyyyyyy"
#[1] "yyyyyyyyyyy"
#or
if(length(unique(vec1))==1) "xxxxxxxxx" else? "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
? if(length(unique(vec2))==1)
2008 Sep 20
1
lower and upper limits in integrate as vectors
Dear R useRs,
i try to integrate the following function for many values
"integrand" <- function(z)
{
return(z * z)
}
i do this with a for-loop
for(i in 2:4)
{
z <- integrate(integrand, i-1, i)$value
cat("z", z, "\n")
}
to speed up the computation for many values i tried vectors
in integrate to do this.
vec1<-1:3
vec2<-2:4
2010 Feb 02
1
Build a matrix from another matrix by specifying the indexes
Hello R specialists,
I have a base vector called vBase with 102 elements. I have another vector
vec1 which elements are only part of vBase but is shorter. I transform vec1
so I get a vector with the same size as vBase and with each common element
on the same indexed row. If a value is missing in vec1 then I put a Na like
this:
vec1 vBase
Amsterdam Amsterdam
Na
2008 Dec 30
2
[LLVMdev] [Mesa3d-dev] Folding vector instructions
Alex wrote:
> Hello.
>
> Sorry I am not sure this question should go to llvm or mesa3d-dev mailing
> list, so I post it to both.
>
> I am writing a llvm backend for a modern graphics processor which has a ISA
> very similar to that of Direct 3D.
>
> I am reading the code in Gallium-3D driver in a mesa3d branch, which
> converts the shader programs (TGSI tokens) to
2010 Aug 24
3
multiple assignments ?
Simple one, have read and googled, still no luck!
I want to create several empty vectors all of the same length.
I would like multiple empty vectors (vec1, vec2, vec3) and want to create them all in one line.
I've tried
vec1,vec2,vec3 <- vector(length=5)
and
c(vec1,vec2,vec3) <- vector(length=5)
and several other attempts but nothing seems to work ... suggestions?
Thanks
Jim