similar to: without a loop

Displaying 20 results from an estimated 7000 matches similar to: "without a loop"

2005 May 18
1
align
Is there a function in R that is similar to Splus's align? The idea is, if I have a data.frame, or an its object that is like this: 2002-01-03 5 2002-01-04 NA 2002-01-05 7 2002-01-06 NA I want to align it by the last value to this: 2002-01-03 5 2002-01-04 5 2002-01-05 7 2002-01-06 7 TITLE: Function align USAGE: align(x, pos, how, error.how, localzone,
2005 May 13
2
without the loop
Can this be re-implemented to run faster (without the loop) ? r <- list() n = nrow(prices) for (i in (w+1):n) { window <- prices[(i-w):(i-1),] if (prices[i,]$settle > max(window$high)) r <- append(r, 1) else if (prices[i,]$settle < min(window$low)) r <- append(r, -1)
2005 Oct 27
3
its dates masked by chron
I built R 2.2.0 from source on my debian machine yesterday and updated all packages. My problem is that "dates" function from its, that my code heavely uses is now masked by "dates" from chron. How can I specify tehat I want to use dates from its or how can I prevent it from being masked? > library(its) Loading required package: Hmisc Hmisc library by Frank E Harrell Jr
2006 Apr 10
3
timeAlign
I use POSIXct for datetimes. Is thee a timeAlign function that I can use where : align by year direction -1 ==> start of this year direction 1 ==> start of next year align by week direction -1 ==> date on last sunday direction 1 ==> date on next sunday align by day direction -1 ==> time at past midnight direction 1 ==> time at this comming
2005 Jun 24
2
seq in R
I want to generate a sequence from 1 to x by 1 seq(1,x,by=1) I want the above to return an empty list if x is zero In other languages I can do 1:x:1 to force the increment by to be a positive 1. This syntax does not work in R. In R 1:x gives me 1 0 when x is zero, this is not what I want. The seq statement above throws an error when x is 0. How can I generate a sequence where if the
2006 May 26
2
Too many open files
This may be more of an OS question ... I have this call r = get.hist.quote(symbol, start= format(start, "%Y-%m-%d"), end= format(end, "%Y-%m-%d")) which does a url request in a loop and my program runs out of file handlers after few hundred rotations. The error message is: 'Too many open files'. Other than increasing the file handlers assigned to my process, is there
2005 May 25
5
precision problem
I have prices that I am finding difficult to compare with ==, > and >, due to precision. For example: the numbers should match, with '==', but they differ in the magnitude of 1e-14 due to bunch of calculations that I run on them. Programming with java, I am used to implementing a function that compares the difference between the numbers to a pre determined precision factor. This
2005 Feb 15
2
how many 7th of the month is there between two dates
This is a eaeir way to ask my prior question: I want to caculate how many an exact day of the month there is between two dates. For example; How many 7th of the month is there between "1998/12/17" and "2000/1/7". To make the problem simple, the day of the month (7) is the day in the 2nd date.
2005 Apr 28
2
how to construct an empty data.frame
> r [1] open settle <0 rows> (or 0-length row.names) > class(r) [1] "data.frame" this is an empty data.frame I get back from a sql statement that returns an empty result set. How can I create such an empty data.frame using the data.frame() constructor? I want to have a data.frame with 0 rows but named empty columns. Thanks in advance for any help.
2005 Oct 06
2
isdst
Can someone, please, explain the difference is results below (notice the isdst value) > unlist(as.POSIXlt('2005-7-1')) sec min hour mday mon year wday yday isdst 0 0 0 1 6 105 5 181 1 > unlist(as.POSIXlt(as.Date('2005-7-1'))) sec min hour mday mon year wday yday isdst 0 0 0 1 6 105 5 181 0
2005 May 13
1
where is aggregateSeries
What package is aggregateSeries in? It is referred to in the fCalendar document but I do not see it in the package.
2006 Apr 10
2
seq
Can someone, please, help explain to me why the following two calls return the same set: > seq(from=as.POSIXlt('2005-12-4'), to=as.POSIXlt('2006-4-2'), by='weeks') [1] "2005-12-04 EST" "2005-12-11 EST" "2005-12-18 EST" "2005-12-25 EST" [5] "2006-01-01 EST" "2006-01-08 EST" "2006-01-15 EST"
2005 Jul 07
1
q() ==> Segmentation fault
I created the simple library, attached. When I terminate an R session where the library has been loaded with q() a segmentation fault is thrown. Is there any cleaning that I should be doing? >From R session: > q() Segmentation fault or from shell: $ R CMD BATCH r.in /usr/lib/R/bin/BATCH: line 55: 17359 Done ( echo "invisible(options(echo = TRUE))"; cat ${in};
2005 Aug 27
1
better than sapply
I have the following two mapping data frames (r) and (h). I want to fill teh value of r$seid with the value of r$seid where r$cid==h$cid. I can do it with sapply as such: > r$seid = sapply(r$cid, function(cid) h[h$cid==cid,]$seid) Is ther a better (faster) way to do this? > r <- data.frame(seid=NA, cid= c(2181,2221,2222)) > r seid cid 1 NA 2181 2 NA 2221 3 NA
2006 May 26
1
R.oo question
This is a simple R.oo question but I, thankfully, hope that someone would explain it to me so I would better understand this work frame. I create this class: setConstructorS3("MyExample", function(param=0) { print(paste("called with param=", param)) extend(Object(), "MyExample", .param = param ); }) >From what is printed out, who made the second call to
2005 Aug 11
3
signal handling
Is ther a signal handling model in R? similar to Perl's %SIG hash. I want to do fast clean up in my R code before exit when a kill signal is issued.
2005 May 11
3
simplify loop
Is there a way to implement this faster than doing it in a loop. for (i in length(settle)-1:1) { settle[i] = settle[i+1]/(1 + settle.pct[i+1]) } I want to guarantee that i+1 is calculated before i
2005 Jun 06
2
names of functions in a library
How can I get a list of the names of all exported functions in a library? I load my library using library() and then want to dynamically get all functions that start with "test." to dynamically execute them.
2004 Dec 13
2
read attribute
How can I get a single attribute value of an object ? I jhave the tiemSeries object > ts1 Open 2003-10-09 02:00:00 1.27 2003-10-10 02:00:00 1.25 2003-10-13 02:00:00 1.27 2003-10-14 02:00:00 1.29 When I unclass ts1 I get: > unclass(ts1) list() attr(,"Data") Open 2003-10-09 02:00:00 1.27 2003-10-10 02:00:00 1.25 2003-10-13 02:00:00 1.27
2005 May 04
1
help track a segmentation fault
I have an R script that I run using nohup R CMD BATCH r.in r.out & The code loops through data from the database and takes hours. The problem is, in about an hour and a half after I start the script the program stops and I get /usr/lib/R/bin/BATCH: line 55: 14067 Done ( echo "invisible(options(echo = TRUE))"; cat ${in}; echo "proc.time()" ) 14068