Displaying 20 results from an estimated 600 matches similar to: "possible loop problem"
2013 Sep 08
1
Sub setting multiple ids based on a 2nd data frame
HI Matt,
I changed the dates a little bit to show dates that are outside the range in dataset B.
A<- read.table(text="
ID????? Date???????????? Depth? Temp
1?????? 2002-05-12?????????? 10 12
1?????? 2003-05-13?????????? 10 12
1?????? 2003-05-14?????????? 10 12
1?????? 2004-04-15?????????? 10 12
2?????? 2002-05-16?????????? 10 12
2?????? 2002-12-17?????????? 10 12
2??????
2013 Sep 27
0
Best and Worst values
Ira,
obj_name<- load("arun.RData")
Pred1<- get(obj_name[1])
Actual1<- get(obj_name[2])
dat2<- data.frame(S1=rep(Pred1[,1],ncol(Pred1)-1),variable=rep(colnames(Pred1)[-1],each=nrow(Pred1)),Predict=unlist(Pred1[,-1],use.names=FALSE),Actual=unlist(Actual1[,-1],use.names=FALSE),stringsAsFactors=FALSE)
dat2New<- dat2[!(is.na(dat2$Predict)|is.na(dat2$Actual)),]
?dat3<-
2013 Jun 10
2
please check this
Hi,
Try this:
which(duplicated(res10Percent))
# [1] 117 125 157 189 213 235 267 275 278 293 301 327 331 335 339 367 369 371 379
#[20] 413 415 417 441 459 461 477 479 505
res10PercentSub1<-subset(res10Percent[which(duplicated(res10Percent)),],dummy==1)? #most of the duplicated are dummy==1
res10PercentSub0<-subset(res10Percent[which(duplicated(res10Percent)),],dummy==0)
2013 Oct 04
3
Trying to avoid nested loop
Dear R users.
I'm trying to avoid using nested loops in the following code but I'm not sure how to proceed. Any help would be greatly appreciated.
With regards,Phil
X = matrix(rnorm(100), 10, 10)
## Version with nested loopsresult = 0
for(m in 1:nrow(X)){ for(n in 1:ncol(X)){ if(X[m,n] != 0){ result = result + (X[m,n] / (1 + abs(m - n))) } }}
## No loop-sum(ifelse(M
2013 Nov 08
2
making chains from pairs
Hello,
having a data frame like test with pairs of characters I would like to
create chains. For instance from the pairs A/B and B/I you get the vector A
B I. It is like jumping from one pair to the next related pair. So for my
example test you should get:
A B F G H I
C F I K
D L M N O P
> test
V1 V2
1 A B
2 A F
3 A G
4 A H
5 B F
6 B I
7 C F
8 C I
9 C K
10 D L
2009 Apr 21
4
My surprising experience in trying out REvolution's R
I care a lot about R's speed. So I decided to give REvolution's R
(http://revolution-computing.com/) a try, which bills itself as an
optimized R. Note that I used the free version.
My machine is a Intel core 2 duo under Windows XP professional. The code
I run is in the end of this post.
First, the regular R 1.9. It takes 2 minutes and 6 seconds, CPU usage
50%
Next, REvolution's R.
2011 Apr 06
5
Need a more efficient way to implement this type of logic in R
I have cobbled together the following logic. It works but is very
slow. I'm sure that there must be a better r-specific way to implement
this kind of thing, but have been unable to find/understand one. Any
help would be appreciated.
hh.sub <- households[c("HOUSEID","HHFAMINC")]
for (indx in 1:length(hh.sub$HOUSEID)) {
if ((hh.sub$HHFAMINC[indx] == '01')
2013 Jun 07
4
matched samples, dataframe, panel data
I R-helpers
#I have a data panel of thousands of firms, by year and industry and
#one dummy variable that separates the firms in two categories: 1 if the firm have an auditor; 0 if not
#and another variable the represents the firm dimension (total assets in thousand of euros)
#I need to create two separated samples with the same number os firms where
#one firm in the first have a corresponding
2002 Sep 01
2
rsync error: unexplained error
I believe I have found the cause of the unexplained error (code ??) at main.c(line #). In the version I'm running 2.5.2 (obtained from the Free Software Foundation) the line number is 576. It appears the root cause is related to a race condition associated with the termination of child processes.
If the signal handler for SIGCHILD is executed, as the result of a child termination, before the
2006 May 26
2
combinatorial programming problem
Hola!
I am programming a class (S3) "symarray" for
storing the results of functions symmetric in its
k arguments. Intended use is for association indices
for more than two variables, for instance coresistivity
against antibiotics.
There is one programming problem I haven't solved, making an inverse
of the index function indx() --- se code below. It could for instance
return the
2012 Mar 09
1
index values of one matrix to another of a different size
> Hello,
>
> Is this the fastest way to use indices from one matrix to reference rows
> in another smaller matrix? I am dealing with very big data (lots of columns
> and I have to do this lots of times).
>
> ######sample data ##############
> vals = matrix(LETTERS[1:9], nrow=3,ncol=3)
> colnames(vals) = c('col1','col2','col3')
> rownames(vals)
2010 Sep 08
0
Correction to vec-subset speed patch
I found a bug in one of the fourteen speed patches I posted, namely in
patch-vec-subset. I've fixed this (I now see one does need to
duplicate index vectors sometimes, though one can avoid it most of the
time). I also split this patch in two, since it really has two
different and independent parts. The patch-vec-subset patch now has
only some straightforward (locally-checkable) speedups for
2010 Feb 22
1
shash in unique.c
Looking at shash in unique.c, from R-2.10.1 I'm wondering if it makes sense
to hash the pointer itself rather than the string it points to?
In other words could the SEXP pointer be cast to unsigned int and the usual
scatter be called on that as if it were integer?
shash would look like a slightly modified version of ihash like this :
static int shash(SEXP x, int indx, HashData *d)
{
2005 Sep 01
1
More block diagonal matrix construction code
Folks:
In answer to a query, Andy Liaw recently submitted some code to construct a
block diagonal matrix. For what seemed a fairly straightforward task, the
code seemed a little "overweight" to me (that's an American stock analyst's
term, btw), so I came up with a slightly cleaner version (with help from
Andy):
bdiag<-function(...){
mlist<-list(...)
## handle case in
2011 Jan 25
0
Map an Area to another
Dear All,
I would like to ask you help with the following:
Assume that I have an area of 36 cells (or sub-areas)
sr<-matrix(data=seq(from=1,to=36),nrow=6,ncol=6,byrow=TRUE)
> sr
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 2 3 4 5 6
[2,] 7 8 9 10 11 12
[3,] 13 14 15 16 17 18
[4,] 19 20 21 22 23 24
[5,] 25 26 27 28 29 30
[6,]
2007 Apr 25
2
[LLVMdev] Work in progress patch to speed up andersen's implementation
Hi guys, i'm not going to have time to work on this for a month or
two, so i figured i'd post it.
This patch
1. reworks the andersen's implementation to support field sensitivity
(though field-sensitive constraints are not generated directly yet),
and uses it to do indirect function call support.
2. Rewrites the solver to be state of the art in terms of speed.
kimwitu++ used to take
2010 Jan 18
0
Fix for bug in match()
Hello all,
I posted the following bug last week:
# These calls work correctly:
match(c("A", "B", "C"), c("A","C"), incomparables=NA) # okay
match(c("A", "B", "C"), "A") # okay
match("A", c("A", "B"), incomparables=NA) # okay
# This one causes R to hang:
match(c("A",
2008 Jul 31
1
Rearranging Data
Hi everyone,
A few days back Jim helped with out, helping me find an automated way of
determining the mean and median of intervals between price changes.
However, a new set of data I have is no longer in the same format.
CDSmod is the file that was used with this code:
x <- read.csv('/cdsmod.csv', as.is=TRUE, check.names=FALSE)
x$Date <- as.Date(x$Date, "%m/%d/%Y")
2008 Aug 16
1
unique.default problem (PR#12551)
Full_Name: Vilmos Prokaj
Version: R 2.7.1
OS: windows
Submission from: (NULL) (213.181.195.84)
Dear developers,
The following line of code (produced by a mistake) caused an infinite loop
unique("a",c("a","b"))
or also
unique(1,1:2)
I made a little investigation, and it seems to be that the following function
from unique.c is looping infinitely
static int
2001 Apr 13
0
LFS changes...
< This patch is against openssh-2.5.2p2 >
Here's a few lines we changed a while back in "scp.c" to get it to
transfer large (>2GB) file on a 32-bit system using LFS. Obviously,
you don't want the line hard-coded in that sets _FILE_OFFSET_BIT=64,
but perhaps you could make it a configure option. (Is it already
perhaps?)
Do you agree that these lines are neccessary