Re: [R] unique with tolerance

2012-09-06 Thread Michael Bach
On 9/6/2012 7:24 PM, Bert Gunter wrote: ... and if it Duncan's suggestion won't do, maybe approaching it via clustering might be useful. But do note that, as stated, the problem is not well defined, because transitivity fails: consider v <- c(1,2,3,4,5,10) with a tolerance of <=2. Then 1 is the

Re: [R] unique with tolerance

2012-09-06 Thread Michael Bach
Thanks to both of you for suggestions. I settled for the round() approach. much obliged, Michael Bach __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

[R] unique with tolerance

2012-09-06 Thread Michael Bach
Dear R Users and Developers, I am trying to do the equivalent of v <- c(1,2,3,3,2,1,) vu <- unique(v) for a vector such as v2 <- c(1.02, 2.03, 1.00, 3.04, 3.06) vut <- ... As indicated in the subject, we need approximately unique values with a defined tolerance, i.e. for the v2 vector the resu

Re: [R] Apply function to every 'nth' element of a vector

2012-04-05 Thread Michael Bach
Thank you very much for your comments Ista and David! I will experiment and see which one serves my needs best. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/po

[R] Apply function to every 'nth' element of a vector

2012-04-05 Thread Michael Bach
ion (x) { return (x*x) } w <- applyfun(v, mysquare, 2) then w should be c(1, 4, 3, 16) Thanks for your time, Michael Bach __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-

[R] R2wd: Insert MS Word field

2012-04-02 Thread Michael Bach
s the subject states, I need a way of inserting this word field from R2wd - something along the lines of: > wdField("<>= plot(1:100)") sadly, I did not find that in the documentation. Any ideas or hints? Best Regards, Michael Bach [1] http://cran.r-project.org/web/packages/R2wd/inde

Re: [R] Specify custom par(mfrow()) layout for defined plot()

2011-05-02 Thread Michael Bach
Prof Brian Ripley writes: > On Mon, 2 May 2011, Michael Bach wrote: > >> Uwe Ligges writes: >> >>> On 29.04.2011 17:10, Michael Bach wrote: >>>> Dear R Users, >>>> >>>> I am doing stats::decompose() on 4 different time serie

Re: [R] Specify custom par(mfrow()) layout for defined plot()

2011-05-02 Thread Michael Bach
Uwe Ligges writes: > On 29.04.2011 17:10, Michael Bach wrote: >> Dear R Users, >> >> I am doing stats::decompose() on 4 different time series. When I issue >> >> csdA<- decompose(tsA) >> plot(csdA) >> >> I get a summary plot for observed,

[R] Specify custom par(mfrow()) layout for defined plot()

2011-04-29 Thread Michael Bach
27;s own plot method where mfrow(4,1) etc. is defined. Now suppose I wanted to wrap those mfrow(4,1) into my own mfrow(2,2) layout. How could I achieve this? Is there a general way to handle these cases? Something like a "meta" par(mfrow())? Best Reg

Re: [R] Reference variables by string in for loop

2011-04-29 Thread Michael Bach
Kenn Konstabel writes: > Another way (not elegant but better and shorter than the eval-parse > way) is to use get. ?get This one is handy for interactive use, thanks for the hint. Kind Regards, Michael Bach __ R-help@r-project.org mailing list

Re: [R] Reference variables by string in for loop

2011-04-29 Thread Michael Bach
for its functional style. > hth. It did, thanks. Kind Regards, Michael Bach __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and prov

[R] Reference variables by string in for loop

2011-04-29 Thread Michael Bach
created variables with names one_df, two_df and three_df earlier in the same script which I want to reference inside the for loop. Is there a more elegant way to do this? Best Regards, Michael Bach __ R-help@r-project.org mailing list https://stat.et

Re: [R] Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
David Winsemius writes: > On Apr 19, 2011, at 8:16 AM, Michael Bach wrote: > >> David Winsemius writes: >> >>> Perhaps but only if the third row of your example was incorrectly >>> constructed: >>>> dta <- rd.txt(" x y z >>>

Re: [R] Odp: Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
Petr PIKAL writes: > Hi > > r-help-boun...@r-project.org napsal dne 19.04.2011 09:46:47: > >> Dear R Users, >> >> Lets assume I have this data frame: >> >> x y z >> 1 1.00 5 0.5 >> 2 1.02 5 0.7 >> 3 1.04 7 0.1 >> 4 1.06 9 0.4 >> >> x and y columns are sorted and the values not necessari

Re: [R] Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
David Winsemius writes: > Perhaps but only if the third row of your example was incorrectly constructed: >> dta <- rd.txt(" x y z > 1 1.00 5 0.5 > 2 1.02 5 0.7 > 3 1.04 7 0.1 > 4 1.06 9 0.4") > #rd.txt() is a combo fn of read.table and textConnection > >> mat <- matrix(NA, ncol=NROW(dta)+1,

[R] Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
es it? All searches I did pointed me to data type frame to matrix conversion... Kind Regards, Michael Bach __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/po

Re: [R] as.matrix strangeness

2011-04-15 Thread Michael Bach
Hi Adrian, thanks for the hint. The problem was that it showed me help for matrix when I did ?as.matrix. I thought it was some kind of convention that data type conversion functions start with "as.", so now I will take more care in the future. With matrix() it works as expected, thanks again.

[R] as.matrix strangeness

2011-04-15 Thread Michael Bach
lly specify nrow=2. It behaves as if I had not given the ncol argument. Any hints on what might be borked up here? R.Version()$ver [1] "R version 2.10.1 (2009-12-14)" Thanks in advance, Michael Bach __ R-help@r-project.org mailing list https:/

[R] debug R device plot

2011-03-24 Thread Michael Bach
Hi there, I was doing great with R, ggplot and tikzDevice, when suddenly it stopped working. I can do a plot just fine on the R online graphics device. I can also open a tikzdevice via tikz(). However, the plot (both ggplot and R graphics plot) call leads to the error: "createLockFile(lockname):

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
bset(dfx, dx > ymd("2007-06-01") & hour(dx) > 10 & hour(x) < 14) > > You are certainly right about that... Best Regards, Michael Bach [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
@Kenn: Yeah I have a way of loosing concentration when fiddling around and trying to get it work. Thanks for pointing out that I supplied a third argument when I wanted an additional test in the second argument instead. Also my selection choices indeed do not make any sense, no wonder your "parser"

Re: [R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
s? Thanks for your help David. On Thu, Mar 24, 2011 at 3:44 PM, David Winsemius wrote: > > On Mar 24, 2011, at 9:29 AM, Michael Bach wrote: > > Dear R users, >> >> Given this data: >> >> x <- seq(1,100,1) >> dx <- as.POSIXct(x*900, origin="

[R] subset and as.POSIXct / as.POSIXlt oddness

2011-03-24 Thread Michael Bach
e following work? 14 > as.POSIXlt(dx)$hour & as.POSIXlt(dx)$hour < 10 Is there something I miss about subset()? Or is there even another way of aggregating over an hourly time interval in a nicer way? Best Regards, Michael Bach [[alternative HTML version deleted]] ___

Re: [R] akima::interp "scales of x and y are too dissimilar"

2011-03-18 Thread Michael Bach
column headers. This caused M[[x]] to evaluate to NULL which in turn triggered the "scales of x and y are too dissimilar" since there is indeed no scale whatsoever in NULL. On Fri, Mar 18, 2011 at 1:21 PM, Duncan Murdoch wrote: > On 18/03/2011 6:37 AM, Michael Bach wrote: > >>

[R] akima::interp "scales of x and y are too dissimilar"

2011-03-18 Thread Michael Bach
attach my csv file? Best Regards, Michael Bach [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and

[R] HoltWinters forecasting method

2011-03-08 Thread Michael Bach
Dear All, I was wondering why the forecast for an additive HoltWinters model is given by Yhat[t+h] = a[t] + h * b[t] + s[t + 1 + (h - 1) mod p]. I am a student and new to time series analysis and forecasting. That said, I considered t = 13 and h = 1: Yhat[13+1] = a[13] + b[13] + s[13 + 1] It see

[R] lattice.wireframe missing wireframe

2011-02-23 Thread Michael Bach
something wrong / addtitional config needed? Thanks in advance, Michael Bach __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commente