search for: worikr

Displaying 20 results from an estimated 41 matches for "worikr".

Did you mean: worik
2010 Jun 16
5
t-test problem
I have two pairs of related vectors x1,y1 and x2,y2 I wish to do a test for differences in means of x1 and y1, ditto x2 and y2. I am getting odd results. I am not sure I am using 'pt' properly... I have not included the raw vectors as they are long. I am interested if I am using R properly... > c(length(x1), length(y1), length(x2), length(y2)) [1] 3436 1619 2677 2378 First
2010 Jun 13
2
Scope and sapply
I am puzzled by the scope rules that apply with sapply. If I want to modify a vector with sapply I tried... N <- 10 vec <- vector(mode="numeric", length=N) test <- function(i){ vec[i] <- i } sapply(1:N, test) vec but it not work. How can this be done? Worik [[alternative HTML version deleted]]
2009 Sep 24
2
Date formats in as.Date
I have trouble with this: as.Date("Sep-1981", format="%b-%Y") Returns "NA" >From documentation for strftime '%b' Abbreviated month name in the current locale. (Also matches full name on input.) '%Y' Year with century. What am I doing wrong? cheers Worik [[alternative HTML version deleted]]
2011 Nov 11
3
Why does length("") == 1?
It seems obvious to me that the empty string "" is length 0. cheers Worik [[alternative HTML version deleted]]
2012 Oct 09
4
Modern Symbolic debugger for R programmes?
I think I am whistling in the wind, but is there a modern symbolic debugger for R programmes? I am working through some one else's code, thousands of lines, that has the occasional bug in it, and a lot in my understanding of it. I cannot make setBreakpoint or findLineNum work. I get "No source refs found.". I am starting to loose my mind! A debugger where I could set
2011 Apr 08
5
Avoiding a loop
Friends. I cannot simplify this much, and I think the loop is unavoidable. As a recovering C programmer I want to avoid loops and in cases like this I almost allways can by using an apply function. But I suspect in this case there is nothing I can do. It is a finance example where a price series is compared to a moving average. If the price goes above the average, plus a bit, buy the
2012 Apr 19
2
Trouble with [sv]apply
Friends I clearly donot understand how sapply and vapply work. What I have is a function that returns a matrix with an indeterminate number of rows (some times zero) but a constant number of columns. I cannot reliably use an apply function to assemble the matrices into a matrix. I am not sure it is possible. I can demonstrate the core of my confusion with this simple code. A.f <-
2010 Aug 30
3
Putting legend *outside* plotting area
Is there a simple way to put a legend outside the plot area for a simple plot? I found... (at http://www.harding.edu/fmccown/R/) # Expand right side of clipping rect to make room for the legend *par(xpd=T, mar=par()$mar+c(0,0,0,4))* # Graph autos (transposing the matrix) using heat colors, # put 10% of the space between each bar, and make labels # smaller with horizontal y-axis labels
2008 Apr 23
2
Incrementing Dates
How can I increment the value of a Date class? I want to add a day, month or year to a date. cheers Worik [[alternative HTML version deleted]]
2008 Apr 23
1
difftime result in years?
I would like to know how many years (including partial years) are between two dates. So difftime("20/11/1962", "20/5/1964", units="years") would be about 1.5 But units of years are not available. cheers Worik [[alternative HTML version deleted]]
2008 Apr 23
1
Time arithmetic
I am a bit worried I am reinventing the wheel. Isn't there a calendar system in R? I have written a function to add months to a date and return the number of days resulting. I am newish to R so I am hoping there is a package that can do this sort of date arithmetic for me... Worik DaysInMonths <- function(s,d){ ## Days in d months from s sdate <- MSTD(s) ## Get day, month
2009 Sep 02
2
Help with sub-setting data.frame
Friends I have a data frame, df that I want to extract some rows from Here is a sample of the data > head(df) TDate Expiry Underlie Strike CSettle PSettle Futures ExDate TTE 1 20080102 200801 200803 0.840 0.0000 0 0.9207 20080104 0.005479452 2 20080102 200801 200803 0.850 0.0000 0 0.9207 20080104 0.005479452 Rate Disc 1 0.0457 0.9997496 2 0.0457
2010 Jun 08
1
Efficiency question
Given the following snippet.... m.nf.xts <- xts(rep(0, length(index(m.xts))), order.by=index(m.xts)) Does R know to cache the index(m.xts) or is it more efficient to say... m.i <- index(m.xts) m.nf.xts <- xts(rep(0, length(m.i)), order.by=index(m.i)) ? cheers Worik [[alternative HTML version deleted]]
2010 Mar 18
1
Locating an error
I have a large programme that after running half an hour or so fails with an error Error in x[value] <- NA : only 0's may be mixed with negative subscripts How can I find out where that error occurs? If I have to do a binary search using error messages it will take a long time! Is there some way I can generate a stack trace? cheers Worik [[alternative HTML version deleted]]
2011 May 05
2
Looking for equivalent for "strstr"
Friends This is an elementary question. Is there is a built in R function for finding a sub-string in another string? Like strstr in C. I can easily roll my own, but if there is a built in that is one less thing I can do wrong! cheers Worik [[alternative HTML version deleted]]
2011 Sep 13
1
Getting Rcpp SEXP data in C++
Friends I am looking at Rcpp and I am a bit stuck on a simple matter. (I am calling R from c++, if there is a better way...) Given this simple example using the TTR package and the SMA function which returns a simple moving average.... Rcpp::NumericVector rv; for(int i = 0; i < 100; i++){ rv.push_back(rand()); } Rcpp::Environment TTR("package:TTR");
2010 Dec 14
1
Modifying values outside a function using "apply".
I am sure this si a simple problem but the solution is evading me. I have a list of matrices all with the same number of columns but different number of rows. The first two columns label the row. The labels are allways the same for the same row numbers, just some matricies have more rows. For example using 3 column matrices... > q.1 <- function(r){return(cbind(seq(0, 10, by=1)[1:r],
2008 Apr 27
1
Lists of data.frame
I cannot find out how to build data structures as lists of data structures. I want to do... r-help@r-project.org d1 <- data.frame(x=1, y=2) d2 <- data.frame(x=1, y=3) d3 <- data.frame(x=21, y=3) q1 <- data.frame(q=d1, n="a") q2 <- data.frame(q=d2, n="a") q3 <- data.frame(q=d3, n="a") v <- vector() or list() or whatever v[1] <- q1 v[2]
2011 May 08
2
Pretty printing numbers
Friends I am trying to format a number to a string so 2189.745 goes to "2,189.35" and 309283.929 goes to "309,283.93" I have tried to use formatC(X, big.mark=",",drop0trailing=FALSE, format="f") but it does not get the number of decimals correct. Specifying digits does not work as that is significant digits. I could use a switch statement switching on
2011 Sep 02
2
Advice on large data structures
Friends I am starting on a (section of the) project where I need to build a matrix with on the order of 5 million rows and 200 columns I am wondering if I can stay in R. I need to do rollapply type operations on the columns, including some that will be functions of (windows of) two columns. I have been looking at the ff and bigmemory packages but am not sure that they will do. Before I get