Re: [R] Help on R Coding

2008-10-04 Thread Yihui Xie
You used variable names 'Date' and 'Cult' in lm2, but *different* names 'Cultc52' and 'Dated16' for prediction. Regards, Yihui -- Yihui Xie <[EMAIL PROTECTED]> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037,

Re: [R] Time Interval calculation using R

2008-10-04 Thread Yihui Xie
You seem to have omitted a left quotation mark in (2): %H:%M:%S". Regards, Yihui -- Yihui Xie <[EMAIL PROTECTED]> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of Ch

Re: [R] Help on R Coding

2008-10-04 Thread andyer weng
Hi all, I am kind of stuck of using Predict function in R to make prediction for a model with continuous variable and categorial variables. i have no problem making the model, the model is e.g. cabbage.lm2<- lm(VitC ~ HeadWt + Date + Cult) HeadWt is a continuous variable, Date and Culte are fac

[R] Time Interval calculation using R

2008-10-04 Thread Gouri Shankar Mishra
Hi I have two columns of data with time in form of HH:MM:SS - representing start time and end time of an activity. I am trying to calculate the time difference (duration of the activity). (1) I first tried > difftime(btime, etime, units = "mins") This however gave me the error - Error in as.POSIX

Re: [R] Help on R Coding

2008-10-04 Thread andyer weng
Hi all, I am kind of stuck of using Predict function in R to make prediction for a model with continuous variable and categorial variables. i have no problem making the model, the model is e.g. cabbage.lm2<- lm(VitC ~ HeadWt + Date + Cult) HeadWt is a continuous variable, Date and Culte are fac

Re: [R] syntax to restrict coefficient in lm()

2008-10-04 Thread Gabor Grothendieck
Frankly, I would do it Duncan's way as that represents it simply as a linear model but if you insist you could use nls. nls(dY ~ a0 - a1 * (Y - b1*X) + b0*dX, DF, start = whatever) On Sat, Oct 4, 2008 at 4:06 PM, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 04/10/2008 3:29 PM, Werner Wernersen

Re: [R] How to plot countours with fixted densities?

2008-10-04 Thread biyeshejiqx
Thanks a lot! It works, however it is less smooth than I had expected. And I have a further question: What if I have my own 2-d density function as: f <- function(x1,x2,parameters) ... and there is no way how to generate random variates (x1,x2) from f. But I'd still like to get the contour

Re: [R] ggplot2: how to combine position=stack and position=dodge in a single graph?

2008-10-04 Thread hadley wickham
Hi Elena, Currently, there's no way to combine stacking and dodging in a single graphic. However, you can often use faceting to get a similar effect to dodging. Could you explain your problem in a little more detail? Thanks, Hadley On Sat, Oct 4, 2008 at 4:22 PM, Elena Schulz <[EMAIL PROTECTE

[R] Error with VAR function of VARS package

2008-10-04 Thread Gabriel Paul Mihalache
I'm trying to get the VAR method of the VARS package to work and I get this weird (probably internal) error: > usvardata CBR CDR RGDPGrowthRate 1610416 8.6 -1.98 16105 15.8 8.6 1.62 ... 16123 14.4 8.6 3.55 16124 14.39 8.52 2.75 > usvar <- V

Re: [R] time segments intersection

2008-10-04 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks. Gabor Grothendieck wrote: Assuming the first row is the comparison row convert to Date class and calculate: DF[] <- lapply(DF, as.Date, format = "%Y/%m/%d") pmin(DF[[2]], DF[1, 2]) - pmax(DF[[1]], DF[1,1]) Please be explicit next time in formulating your queries as requested in the las

Re: [R] time segments intersection

2008-10-04 Thread Gabor Grothendieck
Assuming the first row is the comparison row convert to Date class and calculate: DF[] <- lapply(DF, as.Date, format = "%Y/%m/%d") pmin(DF[[2]], DF[1, 2]) - pmax(DF[[1]], DF[1,1]) Please be explicit next time in formulating your queries as requested in the last line of every message to r-help. O

Re: [R] Number format in log-scaled lattice xyplots

2008-10-04 Thread Deepayan Sarkar
On 10/4/08, Desany, Brian <[EMAIL PROTECTED]> wrote: > For a non-log-scaled y-axis, I was able to change the appearance of the > y tick labels in an xyplot by using a custom function for > yscale.components. However I couldn't get that approach to work for when > scales=list(y=list(log=TRUE)). >

Re: [R] time segments intersection

2008-10-04 Thread [Ricardo Rodriguez] Your XEN ICT Team
Gabor Grothendieck wrote: Mark did not post his response so I don't know what it is. This is Mark's proposal. Sorry, I was speaking about it as if posted to the list. # MAKE POSIXct OBJECTS FROM CHARACTER STRINGS temp1 <- as.POSIXct(strptime("2007-02-02","%Y-%m-%d")) temp2 <- as.POSIXct(

Re: [R] Question about quantile.default

2008-10-04 Thread Ben Bolker
Peter Dalgaard biostat.ku.dk> writes: [snip discussion of overrun in seq()] > > If I don't hear otherwise I will submit this as > > a bug to r-devel ... > > > It IS deliberate We discussed this when R was still in the toddler > stages. > > If you don't allow slight overruns like tha

[R] difference between sm.density() and kde2d()

2008-10-04 Thread Lavan
Dear R users, I used sm.density function in the sm package and kde2d() in the MASS package to estimate the bivariate density. Then I calculated the Kullback leibler divergence meassure between a distribution and the each of the estimated densities, but the asnwers are different. Is there any diff

[R] ggplot2: how to combine position=stack and position=dodge in a single graph?

2008-10-04 Thread Elena Schulz
Hi ggplot experts, I need to plot two time series of stacked data: a barchart with bars for each month. To compare the data of two years I need to combine both time series with in a single graph via position=doge. How should I do that? I tried the following scenario: I added two layers with t

Re: [R] syntax to restrict coefficient in lm()

2008-10-04 Thread Mark Leeds
Werner: what you want done is more easily done using a time series framework. I think there are examples for doing what you want to in the urca package or , if not there, then in the associated book of Bernhard Pfaff. If you send your question to R-Sig-Finance , that may illicit other ideas besides

Re: [R] syntax to restrict coefficient in lm()

2008-10-04 Thread Duncan Murdoch
On 04/10/2008 3:29 PM, Werner Wernersen wrote: Hi, I would like to estimate an error correction model with lm() but I don't find the correct syntax for that. The model (leaving out the time indices) looks like: dY = a0 - a1 * (Y - b1*X) + b0*dX + e the problem is the term - a1 * (Y - b1*X). H

[R] syntax to restrict coefficient in lm()

2008-10-04 Thread Werner Wernersen
Hi, I would like to estimate an error correction model with lm() but I don't find the correct syntax for that. The model (leaving out the time indices) looks like: dY = a0 - a1 * (Y - b1*X) + b0*dX + e the problem is the term - a1 * (Y - b1*X). How can I restrict a1 to be the same for both Y a

Re: [R] Ragged time series data

2008-10-04 Thread Joe Kaser
Thanks Stephen and Gabor. The zoo package is what I was looking for. On Fri, Oct 3, 2008 at 5:44 PM, Gabor Grothendieck <[EMAIL PROTECTED]>wrote: > Check out the zoo package and its three vignettes and > ?aggregate.zoo in particular. > > Also have a look at the article on dates and times in R New

Re: [R] back-solver: any R thing like TK!Solver?

2008-10-04 Thread Gabor Grothendieck
Excel has a solver and Ryacas has limited ability to do symbolic solving: > library(Ryacas) > x <- Sym("x") > y <- Sym("y") > Solve(List(x + y == 1, x - y == 1), List(x, y)) [1] "Starting Yacas!" expression(list(list(x == 1 - y, y == 0))) On Sat, Oct 4, 2008 at 10:07 AM, Carl Witthoft <[EMAIL PR

Re: [R] 3D scatter, groups, RdbiPgSQL...

2008-10-04 Thread Duncan Murdoch
On 03/10/2008 7:19 PM, Tomas Lanczos wrote: Thank You for Your answer, Duncan, Duncan Murdoch wrote: On 03/10/2008 4:33 AM, Tomas Lanczos wrote: hello, I wish to create some 3d scatter diagrams visualising different grouped data set by a given field in the database. I tried the scatterplot3

Re: [R] environment and scoping

2008-10-04 Thread Gabor Grothendieck
Please provide complete examples that include test drivers. Here is main.fun reworked to eliminate the error in the arg list and also changing the environment of aux.fun: main.fun <- function(aux.fun, dat) { x <- 1 environment(aux.fun) <- environment() aux.fun() } aux.fun.one <- function

Re: [R] environment and scoping

2008-10-04 Thread Charles C. Berry
Rene, What you have below does not make much sense. You have not provided a definition for fun.dat() nor have you given an example with which to run any of your functions. The issue you raise about passing 'dat variable as a parameter as it can get pretty large' is not an issue. Observ

Re: [R] environment and scoping

2008-10-04 Thread hadley wickham
What's wrong with explicitly passing the variables as arguments to the function? aux.fun.one <- function(dat, x){ median(dat) - x } Hadley On Sat, Oct 4, 2008 at 11:50 AM, René Holst <[EMAIL PROTECTED]> wrote: > I haven't quite figured out how I can change the environment of a function. > I ha

[R] environment and scoping

2008-10-04 Thread René Holst
I haven't quite figured out how I can change the environment of a function. I have a main function and want to use different auxillary functions, which I supply as parameter (or names). What I want to do is something like this: main.fun=function(aux.fun,dat){ x <- 1 fun.dat() } aux.fun.one

[R] Unload a COM component loaded through RDCOMClient

2008-10-04 Thread DannyAsher
Hi, Is it possible to unload a COM component that is loaded through the RDCOMClient? many thanks, Danny -- View this message in context: http://www.nabble.com/Unload-a-COM-component-loaded-through-RDCOMClient-tp19810731p19810731.html Sent from the R help mailing list archive at Nabble.com. _

[R] Number format in log-scaled lattice xyplots

2008-10-04 Thread Desany, Brian
For a non-log-scaled y-axis, I was able to change the appearance of the y tick labels in an xyplot by using a custom function for yscale.components. However I couldn't get that approach to work for when scales=list(y=list(log=TRUE)). What I'm trying to do is make the y-tick labels show up as some

Re: [R] SAS enterprise guide in R?

2008-10-04 Thread Liviu Andronic
Hello, On Thu, Oct 2, 2008 at 3:50 PM, Hanek Martin <[EMAIL PROTECTED]> wrote: > Our company has been looking at "SAS enterprise guide 4" (Insightful Miner is > a similar product from Insightful, I believe) which seems to provide a nice > graphical way of displaying/managing a process or project

Re: [R] How to plot countours with fixted densities?

2008-10-04 Thread Eik Vettorazzi
Sorry, mixed up where to place the desired level, it has to be done in the plot part, as in d <- kde2d(z1,z2) contour(d, levels=10^(-(2:9)/2), add=T) Eik Vettorazzi schrieb: You may use kde2d from MASS, with estimates a 2d density d <- kde2d(z1,z2,h=10^(-(2:9)/2)) plot(z1,z2) contour(d,add=T

Re: [R] How to plot countours with fixted densities?

2008-10-04 Thread Eik Vettorazzi
You may use kde2d from MASS, with estimates a 2d density d <- kde2d(z1,z2,h=10^(-(2:9)/2)) plot(z1,z2) contour(d,add=T) hth. biyeshejiqx schrieb: Hello,everybody, I used the following codes to generate bivariate normal dependence structure with unit Frechet margins. Sigma <- matrix(c(

[R] back-solver: any R thing like TK!Solver?

2008-10-04 Thread Carl Witthoft
Just thought I'd ask. For those who've never seen TK!Solver, I strongly recommend taking a look. So far as I can tell, it's the only product of its type available, retail or open source, for any platform. What makes TK!Solver so cool is that it adaptively back-solves pretty much any unknown fr

[R] How to plot countours with fixted densities?

2008-10-04 Thread biyeshejiqx
Hello,everybody, I used the following codes to generate bivariate normal dependence structure with unit Frechet margins. Sigma <- matrix(c(1,.5*sqrt(1),.5*sqrt(1),1),2,2) # generate y <- mvrnorm(Nsam, c(0,0), Sigma) # random v <- cbind(pnorm(y[,1],mean = 0, sd = 1), pnorm(y[,2],mean

Re: [R] Simple addition and subtraction doesn't work??

2008-10-04 Thread Uwe Ligges
Erik Iverson wrote: Depending on the class, you might have another teaching opportunity. right away after showing your students that (and why) x + 1 - x = 0 Example: x <- 10^20 x + 1 - x Uwe Ligges See R FAQ 7.31 and the document it points to. Adrian Teo wrote: I was working on

Re: [R] Question about quantile.default

2008-10-04 Thread Gavin Simpson
On Fri, 2008-10-03 at 15:27 -0400, Lo, Ken wrote: > Hi all, > > I am running into a snag using quantile function in stats. Basically, I > don't understand why the loop below throws the error that it does. > > test.data <- rnorm(1000, 0, 1) > > for (i in seq(0.1, 0.001, 0.1)){ > te

[R] How to plot countours with fixted densities?

2008-10-04 Thread biyeshejiqx
Hello, I used the following codes to generate bivariate normal dependence structure with unit Frechet margins. Sigma <- matrix(c(1,.5*sqrt(1),.5*sqrt(1),1),2,2) # generate y <- mvrnorm(Nsam, c(0,0), Sigma) # random v <- cbind(pnorm(y[,1],mean = 0, sd = 1), pnorm(y[,2],mean = 0, sd =

Re: [R] Question about quantile.default

2008-10-04 Thread Peter Dalgaard
Ben Bolker wrote: Lo, Ken roche.com> writes: Hi all, I am running into a snag using quantile function in stats. Basically, I don't understand why the loop below throws the error that it does. test.data <- rnorm(1000, 0, 1) for (i in seq(0.1, 0.001, 0.1)){ test <- quantil

Re: [R] What is the meaning of "segfault 'memory not mapped' " ?

2008-10-04 Thread Peter Dalgaard
Ben Bolker wrote: Ubuntu.Diego gmail.com> writes: I'm trying to get some "easy coding" to reproduce the error. In the meantime I have R code that run for 20 or more hours and suddenly i got a "segfault 'memory not mapped'" error. I have to clarify that the error not alway occurs and sometim