Re: [R] Superimpose two graphs

2011-11-27 Thread Jim Lemon
On 11/28/2011 05:46 PM, Vikram Bahure wrote: Dear R users, I want to superimpose two graphs as well as ensure that they should have same scale with same x& y axis. I am using following command but it does not ensure same scale. *pdf(file = "../RESULTS/RS1.simulated.pdf", width = 10, height =6

[R] Superimpose two graphs

2011-11-27 Thread Vikram Bahure
Dear R users, I want to superimpose two graphs as well as ensure that they should have same scale with same x & y axis. I am using following command but it does not ensure same scale. *pdf(file = "../RESULTS/RS1.simulated.pdf", width = 10, height =6)* *plot(Reserves.RS, col = 1:2, screen = 1)* *

Re: [R] Retain parts of a matrix

2011-11-27 Thread David Winsemius
On Nov 28, 2011, at 12:06 AM, Katrina Bennett wrote: Sorry for not being more clear. I'll try to explain again. I have a rather large DEM and I need to scale daily temperature values for 10 years. I have no idea what a DEM might be. I am using the sapply function to adjust temperatures

Re: [R] system.time

2011-11-27 Thread Jorge I Velez
Hi Vikram, Check ?system.time and ?proc.time. HTH, Jorge.- On Mon, Nov 28, 2011 at 12:41 AM, Vikram Bahure <> wrote: > Dear R users. > > I wanted to know, how do we read the output of system.time. It would be > helpful if you could let me know what are user system and elapsed. > > Regards > Vi

[R] system.time

2011-11-27 Thread Vikram Bahure
Dear R users. I wanted to know, how do we read the output of system.time. It would be helpful if you could let me know what are user system and elapsed. Regards Vikram [[alternative HTML version deleted]] __ R-help@r-project.org mailing list h

Re: [R] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Joshua Wiley
Here is an example, of course, this is predicated on how myfunc() behaves---if it could not handle adding a constant to a vector, things would choke: ## Current method myfunc <- function(x1, x2) { x1 + x2 } x <- 1:10 n <- length(x) A <- matrix(0, nrow = n, ncol = n) for (i in 1:n){ for (j i

Re: [R] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Sachinthaka Abeywardana
Hi Jim, What exactly do you mean by vectorized. I think outer looks like what I was looking for. BUT there was a (weighted) distance matrix calculation that I was trying to vectorize, which wasnt related to this post. Could you proved a bit more details as to what you were referring to, and maybe

Re: [R] Retain parts of a matrix

2011-11-27 Thread David Winsemius
On Nov 27, 2011, at 10:15 PM, Katrina Bennett wrote: Hi all, I'm working to apply a function that will generate a matrix of results only when a specific criteria is met. I want my final results to be a matrix with both the values that meet the criteria (the results of the function), and

Re: [R] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Joshua Wiley
Hi Sachin, The technique you are suggesting is likely to be just as efficient as any other if indeed myfunc must be called on each x[i] x[j] element individually. I would take the additional steps of instantiating A as a matrix (something like: A <- matrix(0, nrow = n, ncol = n) Depending, you

Re: [R] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread jim holtman
Take a look at 'outer' and vectorized your function. Also look at 'expand.grid'. On Sunday, November 27, 2011, Sachinthaka Abeywardana < sachin.abeyward...@gmail.com> wrote: > Hi All, > > I want to do something along the lines of: > for (i in 1:n){ >for (j in 1:n){ >A[i,j]<-myfunc(x[

[R] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Sachinthaka Abeywardana
Hi All, I want to do something along the lines of: for (i in 1:n){ for (j in 1:n){ A[i,j]<-myfunc(x[i], x[j]) } } The question is what would be the most efficient way of doing this. Would using functions such as sapply be more efficient that using a for loop? Note that n can be a

Re: [R] Rprofile.site

2011-11-27 Thread Yen, Steven T
Spencer Thanks! The first approach (source("...)" worked forme. To "put them in an R package", if you tell me what to read to learn it, I will. I am relatively new to R, content to just do the minimum for now to program my own likelihood function using optim. Thanks. again. __

[R] detecting autocorrelation structure in panel data

2011-11-27 Thread Matteo Richiardi
Hello, I'm a newby in R. I have created a data.frame holding panel data, with the following columns: "id","time","y", say: periods = 100 numcases = 100 df = data.frame( id = rep(1:numcases,periods), time = rep(1:periods, each = numcases) ) df = transform(df,y=c(rnorm(numcases*periods)+id) I wan

Re: [R] fitting a distribution to a ecdf plot

2011-11-27 Thread ranmaaa
I wanna get the x and y value of the QQ-plot from this plotdist function. What should I do..?? Thank you Kind regards, Rahma djmuseR wrote > > Hi: > > The fitdistrplus package from CRAN may be useful. I tried it on your data > and the lognormal seemed to fit well, apart from the outlier.

[R] Retain parts of a matrix

2011-11-27 Thread Katrina Bennett
Hi all, I'm working to apply a function that will generate a matrix of results only when a specific criteria is met. I want my final results to be a matrix with both the values that meet the criteria (the results of the function), and those that to do in the same positions in the matrix (the orig

[R] Transform the original data to the "Copula Scale"

2011-11-27 Thread cahaya iman
Hi all, Did R build the function that can transform the original data to the "copula scale" by applying a probability integral transform to obtain uniformly [0; 1]-distributed values? Thank you. Fayyad. [[alternative HTML version deleted]] __

Re: [R] Rprofile.site

2011-11-27 Thread Spencer Graves
or put them in an R package with some appropriate name like "YenMisc", then include "library(YenMisc)" in "Rprofile.site". This has the added advantage that you can easily share YenMisc with others. Spencer On 11/27/2011 6:42 PM, Florent D. wrote: source("c:\path\... ") On Sun, Nov 27, 201

[R] (no subject)

2011-11-27 Thread M Subbiah
http://wyngatecommons.com/wp-content/uploads/2011/06/.log/wyngatecommons.com/lkdmn.htm";>http://wyngatecommons.com/wp-content/uploads/2011/06/.log/wyngatecommons.com/lkdmn.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing l

Re: [R] Rprofile.site

2011-11-27 Thread Florent D.
source("c:\path\... ") On Sun, Nov 27, 2011 at 9:28 PM, Yen, Steven T wrote: > Dear All > > I inserted a frequently used function (subroutine) right into my > Rprofile.site which allows me to run it each time-works great. However, > this approach is obviously suitable for a short function or a s

[R] Rprofile.site

2011-11-27 Thread Yen, Steven T
Dear All I inserted a frequently used function (subroutine) right into my Rprofile.site which allows me to run it each time-works great. However, this approach is obviously suitable for a short function or a small number of functions. Instead of inserting the lines in Rprofile.site, is there a

Re: [R] memory allocation in R

2011-11-27 Thread Simon Urbanek
On Nov 23, 2011, at 10:42 AM, Marc Jekel wrote: > Dear R community, > > I was observing a memory issue in R (latest 64bit R version running on a win > 7 64 bit system) that made me curious. > > I kept track of the memory f my PC allocated to R to calculate + keep several > objects in the work

Re: [R] Missing data?

2011-11-27 Thread Gabor Grothendieck
On Sun, Nov 27, 2011 at 8:10 PM, Kevin Burton wrote: > This has been very helpful. Thank you. > > At the risk of further confirming my ignorance and taxing your patience I > would like to add another question. How would I modify this code so that > each week starts with the same day of the week re

Re: [R] Missing data?

2011-11-27 Thread Kevin Burton
This has been very helpful. Thank you. At the risk of further confirming my ignorance and taxing your patience I would like to add another question. How would I modify this code so that each week starts with the same day of the week regardless of the year? I would add this stipulation so that for

[R] function manipulation for integration

2011-11-27 Thread Sachinthaka Abeywardana
Hi All, I'm trying to use one of the (2D) numerical integration functions, which is not where the problem is. The function definition is as follows: adaptIntegrate(f, lowerLimit, upperLimit, ...) The problem is that I want to integrate a 3D function which has been parametrised such that it is a

Re: [R] Missing data?

2011-11-27 Thread Gabor Grothendieck
On Sun, Nov 27, 2011 at 4:08 PM, Kevin Burton wrote: > I admit it isnt reality but I was hoping through judicious use of these > functions I could approximate reality. For example in the years where there > are more than 53 weeks in a year I would be happy if there were a way to > recognize thi

Re: [R] Missing data?

2011-11-27 Thread R. Michael Weylandt
Back compatibility with other time series best I can tell, but to be honest, I'm not even sure how it plays into that. Perhaps it's just an artifact in the signature. It doesn't seem to have a role in the xts constructor. E.g., identical(xts(1:5, Sys.Date()+1:5, frequency = 1), xts(1:5, Sys.Date(

Re: [R] Missing data?

2011-11-27 Thread Kevin Burton
I was just trying to be complete. Why is the frequency argument and attribute available? -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Saturday, November 26, 2011 2:40 PM To: Kevin Burton Cc: r-help@r-project.org Subject: Re: [R] Missing data? Why

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread David Winsemius
On Nov 27, 2011, at 1:00 PM, Florent D. wrote: ... but the original request was to build a series, not approximate its limit by building a different (but "faster") series. Right. Your function was faster that the earlier ones. But if speed were the issue, it might make more sense to use mat

Re: [R] Missing data?

2011-11-27 Thread Kevin Burton
I admit it isnt reality but I was hoping through judicious use of these functions I could approximate reality. For example in the years where there are more than 53 weeks in a year I would be happy if there were a way to recognize this and drop the last week of data. If there were less than 53 I

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread R. Michael Weylandt
You can write a function to do so and then there are all sorts of options of what to do with it - mostly they degenerate into putting it in a personal package or into your .Rprofile for convenient use. If you want to use compiled code, that's slightly trickier but good facilities exist to do so

[R] dismo help

2011-11-27 Thread Hasan Diwan
savePngCentredAt <- function(address) { require(dismo) x <- geocode(address) range <- as.numeric(x[4:7]) + c(-0.01, 0.01, -0.01, 0.01) e <- extent(range) g <- gmap(e, type = "roadmap") require(digest) png(path.expand(paste('~/public_html/',digest(address, algo='sha1'),'.png',sep='')))

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread William Dunlap
The following quickly does the recursion suggested by Florent D.: loopRec5 <- function(x, alpha) { as.vector(filter(x*alpha, alpha, method="recursive")) } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r

[R] (no subject)

2011-11-27 Thread M Subbiah
http://maininfocenter.net/wp-content/plugins/extended-comment-options/wopqr.htm";>http://maininfocenter.net/wp-content/plugins/extended-comment-options/wopqr.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://st

Re: [R] Simplifying my code

2011-11-27 Thread jim holtman
Consider the use of a 'list' dat <- lapply(1:20, function(i) complete(dat.mice, i)) On Sun, Nov 27, 2011 at 12:52 PM, R. Michael Weylandt wrote: > But it's much better to preallocate memory: > > dat = vector("list", 20) > or > dat = vector("numeric", 20) > or > dat = matrix(nrow = 20, ncol = ?

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread Florent D.
... but the original request was to build a series, not approximate its limit by building a different (but "faster") series. What I suggested is linear in terms of the size of x so you won't find a faster algorithm. What will make a difference is the implementation, e.g. C loop versus R loop. O

Re: [R] Simplifying my code

2011-11-27 Thread R. Michael Weylandt
But it's much better to preallocate memory: dat = vector("list", 20) or dat = vector("numeric", 20) or dat = matrix(nrow = 20, ncol = ??) as needed (put the right # of columns in for the matrix) Michael On Nov 27, 2011, at 11:24 AM, andrija djurovic wrote: > Hi. > You haven't specified objec

Re: [R] conflict when passing an argument to a function within an other function

2011-11-27 Thread Duncan Murdoch
On 11-11-27 10:32 AM, Sylvain Antoniazza wrote: Dear all, I have a problem with this piece of code which I don't really see how to overcome and I think it might also be of more general interest: map(xlim=c(-10,40),ylim=c(30,60) ,mar=rep(0,4)+.1 ,fill=T ,col="darkseagreen" ,bg="skyblue" ) The

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread Yen, Steven T
Hi Is there a way to link a frequently-used sub-routine (in binary form or preferably in ascii form) in a program, similar to the following in Gauss? Thanks. #include c:\programs\mylib1.g; -- Steven T. Yen, Professor of Agricultural Economics The University of Tennessee http://web.utk.edu/~syen

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread David Winsemius
On Nov 27, 2011, at 9:25 AM, R. Michael Weylandt wrote: You also might look at EMA() in the TTR package for a C implementation. (I think it matches your problem but can't promise) It's pretty close for EMA(1:1000, n=1, ratio=0.5) and 7 times faster. > EMA(1:10, n=1, ratio=0.5) [1] 1.00

Re: [R] SPSS -> R

2011-11-27 Thread Kristi Shoemaker
Hi John, Your assumptions are correct and those examples were very helpful, thanks! I think I'm almost there, but I'm screwing up something with the within-subjects factor (the example has two, I only have one). See below. Why am I not seeing my within-subjects factors in the ANOVA report? >

Re: [R] Simplifying my code

2011-11-27 Thread andrija djurovic
Hi. You haven't specified object to store results. Try something like: dat = c() #or dat = list() or matrix with specified ncol and nrow for(i in 1:20){ dat[i]=complete(dat.mice,[i] } On Sun, Nov 27, 2011 at 4:02 PM, Christopher Desjardins wrote: > Hi, > I have a pretty simple problem. Here i

[R] conflict when passing an argument to a function within an other function

2011-11-27 Thread Sylvain Antoniazza
Dear all, I have a problem with this piece of code which I don't really see how to overcome and I think it might also be of more general interest: map(xlim=c(-10,40),ylim=c(30,60) ,mar=rep(0,4)+.1 ,fill=T ,col="darkseagreen" ,bg="skyblue" ) The idea is to use the map function from the maps packa

[R] Simplifying my code

2011-11-27 Thread Christopher Desjardins
Hi, I have a pretty simple problem. Here is the code: dat1=complete(dat.mice,1) dat2=complete(dat.mice,2) dat3=complete(dat.mice,3) dat4=complete(dat.mice,4) dat5=complete(dat.mice,5) dat6=complete(dat.mice,6) dat7=complete(dat.mice,7) dat8=complete(dat.mice,8) dat9=complete(dat.mice,9) d

Re: [R] I cannot get species scores to plot with site scores in MDS when I use a distance matrix as input. Problems with NA's?

2011-11-27 Thread Edwin Lebrija Trejos
Hi, I have used the daisy() function from the package "cluster" as suggested. Indeed it can handle Na's but this is not different from the gowdis() function in Package "FD". My problem is not calculating the similarity matrix for its use with the metaMDS() function. My problem is that because I

Re: [R] Question about randomForest

2011-11-27 Thread Weidong Gu
Matthew, Your intepretation of calculating error rates based on the training data is incorrect. In Andy Liaw's help file "err.rate-- (classification only) vector error rates of the prediction on the input data, the i-th element being the (OOB) error rate for all trees up to the i-th." My underst

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread R. Michael Weylandt
You also might look at EMA() in the TTR package for a C implementation. (I think it matches your problem but can't promise) Michael On Nov 27, 2011, at 9:05 AM, Michael Kao wrote: > Hi Florent, > > That is great, I was working on solving the recurrence equation and this was > part of that eq

[R] Need Help with my Code for complex GARCH (GJR)

2011-11-27 Thread Lin23
Hello, i want to estimate a complex GARCH-model (see below). http://r.789695.n4.nabble.com/file/n4112396/GJR_Garch.png W stands for the Day of the Week Dummies. r stands for returns of stock market indices. I stands for the GJR-term. I need some help with three problems: 1.) implementation of t

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread Michael Kao
Hi Florent, That is great, I was working on solving the recurrence equation and this was part of that equation. Now I know how to put everything together, thanks for all the help e everybody! Cheers, On 27/11/2011 2:05 p.m., Florent D. wrote: You can make things a lot faster by using the re

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread Florent D.
You can make things a lot faster by using the recurrence equation y[n] = alpha * (y[n-1]+x[n]) loopRec <- function(x, alpha){ n <- length(x) y <- numeric(n) if (n == 0) return(y) y[1] <- alpha * x[1] for(i in seq_len(n)[-1]){ y[i] <- alpha * (y[i-1] + x[i]) } return(y)

Re: [R] Boxplot

2011-11-27 Thread Jakson Alves de Aquino
On Sun, Nov 27, 2011 at 2:15 AM, Jeffrey Joh wrote: > I'm trying to do the second case among Jim's suggestions.  I used > Bert's suggestion and it works great. > > I would also like to ask if anyone is familiar with a package for > making box-plots.  I would like to bin my datapoints at defined X

Re: [R] tikzDevice and sans serif

2011-11-27 Thread David Winsemius
On Nov 27, 2011, at 1:46 AM, Thomas S. Dye wrote: Aloha all, I haven't been able to find how to choose the font used by tikzDevice. My first tries have all been set with a serif font and I'd like to have them use the sans serif font instead. I've looked through the documentation and google

Re: [R] Transforming a string into a command

2011-11-27 Thread andrija djurovic
?eval s<- expression(log(a+b)) a<-1 b<-2 eval(s) Andrija On Sun, Nov 27, 2011 at 11:16 AM, Victor wrote: > I would like to make a string executable, e.g, > > s<- "ln(a+b)" > a<-1 > b<-2 > > execute string s to obtain ln(a+b) > > How can I make it? > > Ciao fron Rome > Vittorio > > ___

Re: [R] Transforming a string into a command

2011-11-27 Thread Michael Kao
This is one way to do it. a = 1 b = 2 c = parse(text = "log(a + b)") eval(c) Hope this helps. Cheers, On 27/11/2011 11:16 a.m., Victor wrote: I would like to make a string executable, e.g, s<- "ln(a+b)" a<-1 b<-2 execute string s to obtain ln(a+b) How can I make it? Ciao fron Ro

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread Michael Kao
Dear Enrico, Brilliant! Thank you for the improvements, not sure what I was thinking using rev. I will test it out to see whether it is fast enough for our implementation, but your help has been SIGNIFICANT!!! Thanks heaps! Michael On 27/11/2011 10:43 a.m., Enrico Schumann wrote: Hi Michael

[R] Transforming a string into a command

2011-11-27 Thread Victor
I would like to make a string executable, e.g, s<- "ln(a+b)" a<-1 b<-2 execute string s to obtain ln(a+b) How can I make it? Ciao fron Rome Vittorio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

2011-11-27 Thread Enrico Schumann
Hi Michael here are two variations of your loop, and both seem faster than the original loop (on my computer). require("rbenchmark") ## your function loopRec <- function(x, alpha){ n <- length(x) y <- double(n) for(i in 1:n){ y[i] <- sum(cumprod(rep(alpha, i)) * rev(x[1:i

Re: [R] Question about randomForest

2011-11-27 Thread Ken
I am pretty sure that when each tree is fitted the error rate for tree 'i' is it's performance on the data which was not used to fit the ith tree (OOB). In this way cross validation is performed for each tree but I do not think that all trees fitted prior are involved in the computation of that

Re: [R] Question about randomForest

2011-11-27 Thread Matthew Francis
Thanks for the help. Let me explain in more detail how I think that randomForest works so that you (or others) can more easily see the error of my ways. The function first takes a random sample of the data, of the size specified by the sampsize argument. With this it fully grows a tree resulting i