similar to: Is it possible to vectorize/accelerate this?

Displaying 20 results from an estimated 10000 matches similar to: "Is it possible to vectorize/accelerate this?"

2011 Mar 15
4
Element by element mean of a list of matrices
Hi All, is there any effiective and dense/compact method to calculate the mean of a list of - of course coincident - matrices on an element by element basis? The resulting matrix' [i, j]-th element is the mean of the list's matrices' [i, j]-th elements respectively... Iterating by for statement is quite straightforward, but I am seeking for a more elegant solution, and my attempt with
2009 Feb 16
2
solve.QP with box and equality constraints
Dear list, I am trying to follow an example that estimates a 2x2 markov transition matrix across several periods from aggregate data using restricted least squares. I seem to be making headway using solve.QP(quadprog) as the unrestricted solution matches the example I am following, and I can specify simple equality and inequality constraints. However, I cannot correctly specify a constraint
2013 Jan 24
3
ifelse to speed up loop?
Hello, I'm not sure how to explain what I'm looking for but essentially I have a test dataset that looks like this: test: V1 1 1 2 1 3 1 4 2 5 2 6 2 7 1 8 1 9 1 10 2 11 2 12 2 And what I want to be able to do is create another column that captures a "grouping" variable that looks like this: test V1 group 1 1 1 2 1 1 3 1 1 4 2 2 5 2
2016 Jan 29
3
Validate Ids Multiple DC
Lol... I dont know.. and i did learn know most from you :-P And you have reset the idmap? Greetz, .. hihi... Louis > -----Oorspronkelijk bericht----- > Van: samba [mailto:samba-bounces at lists.samba.org] Namens Rowland penny > Verzonden: vrijdag 29 januari 2016 16:22 > Aan: samba at lists.samba.org > Onderwerp: Re: [Samba] Validate Ids Multiple DC > > On 29/01/16
2016 Aug 01
2
Centos 7 & ntlm
Hihi So I have a really strange problem. I am running Centos 7 with Samba purely for ntlm_auth against winbind services (squid/radius auth etc). Its been working fine till we found a strange bug with the ntlm_auth executable. If the username has a "w" at the end it throws out a syntax error see below test: # ./ntlm_auth --username=lblaauw username must be specified! Usage:
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?
2004 Aug 18
5
labeled break statements in R?
Hi, Are there labeled break statements in R? i.e., something along the lines of TOPLOOP: for(i in 1:m) { for(j in 1:n) { ... if(condition) { break TOPLOOP } } } Thanks, Roger
2005 Jun 16
5
Vectorization
Greetings, Can anyone suggest me if we can vectorize the following problem effectively? I have two datasets, one dataset is portfolio of stocks returns on a historical basis and another dataset consist of a bunch of factors (again on a historical basis). I intend to compute a rolling n-day sensitivitiesfor each stock for each factor, so the output will be a data frame with
2012 Feb 07
2
Vectorizing a loop
Hello Folks, I'm trying to vectorize a loop that processes rows of a dataframe. It involves lots of conditionals, such as "If column 10 == 3, and if column 3 is True, and both column 5 and 6 are False, then set column 4 to True". So, for example, any ideas about vectorizing the following? df = data.frame( list(a=c(1,2,3,4),
2011 Mar 29
1
new syntax: bash-like pipe operator
Dear R Community, One thing that always bugged me about R is the abundance of multi-level nested statements, like: cumsum(ifelse(c(1,diff(v)),1,0)) because: a) you have to read them inside out as opposed to left-to-right b) in the console you always have to go back and type the parenthesis if you want to nest your statement I kind of like the UNIX pipe operator as a very good abstraction of a
2011 Aug 03
4
slow computation of functions over large datasets
Hello there, I’m computing the total value of an order from the price of the order items using a “for” loop and the “ifelse” function. I do this on a large dataframe (close to 1m lines). The computation of this function is painfully slow: in 1min only about 90 rows are calculated. The computation time taken for a given number of rows increases with the size of the dataset, see the example with
2012 Mar 19
3
Issue with asin()
Hello everyone, I am working for a few days already on a basic algorithm, very common in applied agronomy, that aims to determine the degree-days necessary for a given individual to reach a given growth stade. The algorithm (and context) is explained here: http://www.oardc.ohio-state.edu/gdd/glossary.htm , and so I implemented my function in R as follows: DD <- function(Tmin, Tmax, Tseuil,
2010 Nov 01
2
how to save this result in a vector
HI, Dear R community, I have the following codes to calculate the commulative coverage. I want to save the output in a vector, How to do this? test<-seq(10, 342, by=2) #cover is a vector cover_per<-function (cover) { for (i in min(cover):max(cover)) {print(100*sum(ifelse(cover >= i, 1, 0))/length(cover))} } result<-cover_per(test) > result NULL Can anyone help me this this?
2013 May 07
4
how to calculate the mean in a period of time?
Hi, Your question is still not clear. May be this helps: dat2<- read.table(text=" patient_id????? t???????? scores 1????????????????????? 0??????????????? 1.6 1????????????????????? 1??????????????? 2.6 1????????????????????? 2???????????????? 2.2 1????????????????????? 3???????????????? 1.8 2????????????????????? 0????????????????? 2.3 2?????????????????????? 2???????????????? 2.5
2001 Nov 16
1
R BATCH mode
hihi easy! i would like run r in batch mode. how could i pass through arguments for my r.script. for example: r batch my_script.R arg1 arg2 and how must i modify the r script. wolfgang -- Wolfgang Mueller Phone +41 1 256-9203, MeteoSwiss Kraehbuehlstr. 58, mailto:muw at meteoswiss.ch CH-8044 Zuerich, Switzerland http://www.meteoswiss.ch/
2001 Nov 15
2
matrices
hihi i've a matrix say a(30,10,5). how can a function (for example histogram) be used to calculate along the first axis, or to create a 10x5 matrix of histograms? wolfgang -- Wolfgang Mueller Phone +41 1 256-9203, MeteoSwiss Kraehbuehlstr. 58, mailto:muw at meteoswiss.ch CH-8044 Zuerich, Switzerland http://www.meteoswiss.ch/
2010 Nov 25
4
Cumsum with a max and min value
I have a vector of values -1, 0, 1, say a <- c(0, 1, 0, 1, 1, -1, -1, -1, 0, -1, -1) I want to create a vector of the cumulative sum of this, but I need to set a maximum and minimum value for the cumsum, for example: max_value <- 2 min_value <- -2 the expected result would be (0, 1, 1, 2, 2, 1, 0, -1, -1, -2, -2) The only way I managed to do It, was res <-
2009 Sep 30
5
Condition to factor (easy to remember)
Dear List, creating factors in a given non-default orders is notoriously difficult to explain in a course. Students love the ifelse construct given below most, but I remember some comment from Martin M?chler (?) that ifelse should be banned from courses. Any better idea? Not necessarily short, easy to remember is important. Dieter data = c(1,7,10,50,70) levs =
2007 May 21
2
sequentially process a list
Hi dear R users, I'm a R beginner and I have a basic question about sequential treatments of lists. I have a time based (i.e. events are consecutive) list of values of a biological property. Like : time value 1 5 2 10 3 7 4 10 5 19 6 21 7 20 8 18 9 10 10 7 11 8 12 12 13 17 14 19 15 24 16 18 17 15 18
2007 Aug 22
3
Help with vector gymnastics
Hello, What is the best way of solving this problem? answer <- ifelse(tf=TRUE, i * 5, previous answer) where as an initial condition tf[1] <- TRUE For example if, tf <- c(T,F,F,F,T,T,F) over i = 1 to 7 then the output of the function will be answer = 5 5 5 5 25 30 30 Thank you. Phil,