Re: [R] Plotting a functional time series

2011-02-24 Thread Eduardo de Oliveira Horta
Thanks a lot! Regards, Eduardo On Thu, Feb 24, 2011 at 6:47 PM, David Winsemius wrote: > > On Feb 24, 2011, at 3:06 PM, Eduardo de Oliveira Horta wrote: > >> It seems the code I've sent had typos... >> >> Here's a corrected version: >> >>

Re: [R] Plotting a functional time series

2011-02-24 Thread Eduardo de Oliveira Horta
f,theta=-50, phi=30, d=2) win.graph() opar <- par(mfrow=c(5,2), mar=c(2,2,1,1)) sapply(1:10, function(i)plot(grid, f[,i], ann=FALSE, type="l")) par(opar) # Sorry for the mistake. Best regards, Eduardo On Mon, Feb 21, 2011 at 11:18 PM, Eduardo d

[R] Plotting a functional time series

2011-02-21 Thread Eduardo de Oliveira Horta
Hello, I'm willing to plot a sequence of densities on a 3d graph, something like - x <- sapply(1:10, function(i)rnorm(1000)) f <- sapply(1:10, function(i)density(x[,i], from=-5,to=5)$y) grid <- density(x[,1], from=-5,to=5)$x win.gr

Re: [R] Building an array from matrix blocks

2011-02-21 Thread Eduardo de Oliveira Horta
-p-1+i),i:(n-p-1+i)])) > > I imagine someone can be even more eleganter than this. > > rad > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Eduardo de Oliveira Horta > Sent: Saturday, February 19, 2011 9:

[R] Building an array from matrix blocks

2011-02-19 Thread Eduardo de Oliveira Horta
Hello, I've googled for a while and couldn't find anything on this topic: say I have a matrix A and want to build matrices B1, B2,... using blocks from A (or equivalently an array B with B[,,i] being a block from A), and that I must sum the B[,,i]'s. I've come up with this rather non-elegant code

Re: [R] Defining functions inside loops

2011-02-15 Thread Eduardo de Oliveira Horta
+             function(x)x^2+local_s > +           })) >> rm(s) >> f[[2]](4) > [1] 16.45 >> > > > > On Tue, Feb 15, 2011 at 10:53 AM, Eduardo de Oliveira Horta > wrote: >> Thanks... but I guess I didn't make myself clear. What I was trying to >> do was precise

Re: [R] Defining functions inside loops

2011-02-15 Thread Eduardo de Oliveira Horta
gt; [1] 0.21 > >> for(i in 1:10) print(f[[i]](i)) > [1] 1.2 > [1] 4.45 > [1] 9.38 > [1] 16.9 > [1] NA > [1] NA > [1] NA > [1] NA > [1] NA > [1] NA > >> for(i in 1:10) print(f[[i]](1)) > [1] 1.2 > [1] 1.45 > [1] 1.38 > [1] 1.9 > [1] NA >

Re: [R] Defining functions inside loops

2011-02-14 Thread Eduardo de Oliveira Horta
can find it in f[[7]]'s environment >>    > get("i", envir=environment(f[[7]])) >>    [1] 7 >> >> The call to force() in the call to local() is not >> necessary in this case, although it can help in >> other situations. >> >> Bill Dun

Re: [R] Average of several line plots

2011-02-02 Thread Eduardo de Oliveira Horta
It is not clear from your message whether these data represent functions or such. Could you perhaps bring up an example? I'm guessing each data set contains evaluation points and function values at those points, and that you would like to plot these functions and the mean function all on the same

Re: [R] R-/Text-editor for Windows?

2011-01-30 Thread Eduardo de Oliveira Horta
I'm testing StatET right now. Seems nice. In many aspects it resembles the features offered by RKWard (which is a KDE application and thus also platform independent... in principle. No pre-compiled OSX version yet). For those interested, I found an explanation on how to set StatET running. Might b

Re: [R] R-/Text-editor for Windows?

2011-01-29 Thread Eduardo de Oliveira Horta
Sascha, I guess the software you wan't is RKWard: http://rkward.sourceforge.net/ I have tested a few R front-ends and to me this one seemed the most adequate. I suppose as an ex-matlab user my interface preferences are biased, but still RKWard has a good editor with syntax highlighting, code fol

[R] pdf greek letter typos

2011-01-26 Thread Eduardo de Oliveira Horta
Hi there, yet on the topic of greek letters and pdf plotting: when I run the following code pdf(file="temp.pdf") mu=seq(from=-pi, to=pi, length=100) plot(mu, sin(mu^2), type="l", xlab=expression(mu%in%(list(-pi,pi))), ylab=expression(sin(mu^2)), main=expression((list(mu,sin(mu

[R] Greek letters in CairoPDF

2011-01-26 Thread Eduardo de Oliveira Horta
Hello there, Straight to the point: it seems that CairoPDF from package "Cairo" cannot handle greek letters from expression(). For example, > eta = seq(from=-pi, to=pi, length=100) > f = sin(eta)^2 > pdf(file = "temp_pdf.pdf") > plot(eta, f, type="l", main=expression(f(eta)==sin(eta)^2), > xlab=

Re: [R] Alphabetic labels on multi-plot graphics

2011-01-11 Thread Eduardo de Oliveira Horta
Thanks, I wasn't even aware that 'letters' was there. Best regards On Tue, Jan 11, 2011 at 6:08 PM, David Winsemius wrote: > > On Jan 11, 2011, at 2:06 PM, Eduardo de Oliveira Horta wrote: > >> Is there a way to achieve >> >> lbl=c("a", &quo

[R] Alphabetic labels on multi-plot graphics

2011-01-11 Thread Eduardo de Oliveira Horta
Is there a way to achieve lbl=c("a", "b", "c", "d") par(mfrow=c(2,2), ann=FALSE) for (t in 1:4){ plot(seq(from=1,to=2*pi,length=100), sin(t*seq(from=1,to=2*pi,length=100)), type="l") title(main=paste("(", lbl[t], ")", sep="")) } without having to use an object like 'lbl'? More generally: is

Re: [R] Cairo pdf canvas size

2011-01-07 Thread Eduardo de Oliveira Horta
Thanks! On Thu, Jan 6, 2011 at 7:13 PM, Dennis Murphy wrote: > Hi: > > On Thu, Jan 6, 2011 at 5:36 AM, Eduardo de Oliveira Horta > wrote: >> >> Peter, >> thank you, that's what I was looking for! >> David, I forgot to tell you my OS. Sorry... it's

Re: [R] Cairo pdf canvas size

2011-01-06 Thread Eduardo de Oliveira Horta
series, so each observation is a function (or a vector representing that function evaluated on a grid) indexed by time. Any insights on how to implement data frames here? Best regards, Eduardo On Thu, Jan 6, 2011 at 1:47 AM, Peter Langfelder wrote: > On Wed, Jan 5, 2011 at 7:35 PM, Eduardo

Re: [R] Cairo pdf canvas size

2011-01-05 Thread Eduardo de Oliveira Horta
q(from=xlim[1], to=xlim[2], length=5), lwd=.25,lty="dotted", col="grey") abline(h=seq(from=ylim[1], to=ylim[2], length=5), lwd=.25,lty="dotted", col="grey") dev.off() Notice how the canvas' margins are relatively far from the plotting area. Thanks, Eduar

[R] Cairo pdf canvas size

2011-01-05 Thread Eduardo de Oliveira Horta
Hello, I want to save a pdf plot using Cairo, but the canvas of the saved file seems too large when compared to the actual plotted area. Is there a way to control the relation between the canvas size and the size of actual plotting area? Thanks in advance, and best regards, Eduardo Horta

Re: [R] Adding lines in ggplot2

2011-01-05 Thread Eduardo de Oliveira Horta
I thank you all for the insightful answers. I'm quite a rookie in R and have built a code that didn't take data frames into account. But I suppose I'm now convinced that they're actually a practical structure for organizing the data... so I'll adhere to the Data Frame Club soon enough. Best regard

[R] Adding lines in ggplot2

2011-01-04 Thread Eduardo de Oliveira Horta
Hello, this is probably a recurrent question, but I couldn't find any answers that didn't involve the expression "data frame"... so perhaps I'm looking for something new here. I wanted to find a code equivalent to > x=sqrt(1:10) > y=log(1:10) > plot(1:10, x, type="lines", col="darkgreen") > line

Re: [R] Saving objects inside a list

2011-01-04 Thread Eduardo de Oliveira Horta
hat RKWard doesn't > use .GlobalEnv in the usual way. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -Original Message- > > From: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-project.org] On Behalf Of Eduard

Re: [R] Saving objects inside a list

2011-01-04 Thread Eduardo de Oliveira Horta
oblist$B [1] 1000 Problem solved? Best regards, Eduardo Horta On Tue, Jan 4, 2011 at 9:41 AM, Olivier ETERRADOSSI < olivier.eterrado...@mines-ales.fr> wrote: > Message: 42 >> Date: Mon, 3 Jan 2011 18:58:04 -0200 >> From: Eduardo de Oliveira Horta >> >> To: r-

Re: [R] Saving objects inside a list

2011-01-03 Thread Eduardo de Oliveira Horta
sapply(ls(),get) works fine. Thanks. ps: the as.list and the eapply suggestions didn't work. On Mon, Jan 3, 2011 at 3:56 PM, Jorge Ivan Velez wrote: > Hi Eduardo, > > Try > > r <- ls() > result <- sapply(r, get) > result > > HTH, > Jorge > >

Re: [R] Saving objects inside a list

2011-01-03 Thread Eduardo de Oliveira Horta
> On Mon, Jan 3, 2011 at 3:25 PM, Eduardo de Oliveira Horta < > eduardo.oliveiraho...@gmail.com> wrote: > >> Hello there, >> >> any ideas on how to save all the objects on my workspace inside a list >> object? >> >> For example, say my workspace is

[R] Saving objects inside a list

2011-01-03 Thread Eduardo de Oliveira Horta
Hello there, any ideas on how to save all the objects on my workspace inside a list object? For example, say my workspace is as follows ls() [1] "x" "y" "z" and suppose I want to put these objects inside a list object, say object.list <- list() without having to explicitly write down their nam

[R] Finding indexes of minum and maximum elements of an array

2010-12-27 Thread Eduardo de Oliveira Horta
1 and > max(H) [1] 8 Say "idx" were the function I'm looking for. Then, what I'm expecting is > idx(min(H)) [1] 1 1 2 > idx(max(H)) [1] 1 1 1 Thanks in advance, Eduardo de Oliveira Horta [[alternative HTML version deleted]]

Re: [R] Removing elements of a list object

2010-12-23 Thread Eduardo de Oliveira Horta
Thanks! On Thu, Dec 23, 2010 at 3:24 PM, Henrique Dallazuanna wrote: > Try this: > > x$second <- NULL > > > On Thu, Dec 23, 2010 at 3:21 PM, Eduardo de Oliveira Horta < > eduardo.oliveiraho...@gmail.com> wrote: > >> Hello, >> >> say I have

Re: [R] Integration with LaTex and LyX

2010-12-23 Thread Eduardo de Oliveira Horta
> Yihui > -- > Yihui Xie > Phone: 515-294-2465 Web: http://yihui.name > Department of Statistics, Iowa State University > 2215 Snedecor Hall, Ames, IA > > > > On Mon, Dec 13, 2010 at 9:27 AM, Eduardo de Oliveira Horta > wrote: > > Hello, > > > >

[R] Removing elements of a list object

2010-12-23 Thread Eduardo de Oliveira Horta
Hello, say I have an object > x = list(first = 10, second = 20, third = "Yeah!") and want to remove the $second element of that list. My first try was, of course, > rm(x$second) which gave me the following error message > Error in rm(x$second) : ... must contain names or character strings An

Re: [R] Integrate two function in R

2010-12-16 Thread Eduardo de Oliveira Horta
I guess what you have is g <- function(x){ 2*x-3 } s <- function(x){ 5*x^2+2 } and what you want is f<-function(x){ g(x)*s(x) } integrate(f,a,b) Try that and see if it works. If not (that is, if your actual g and s are not as in the example), maybe you'll have to do this: integrate(Vectorize(

[R] Integration with LaTex and LyX

2010-12-13 Thread Eduardo de Oliveira Horta
Hello, Are there any packages which allow for a good integration between R and LaTex / LyX? I'm interested mainly in automatic (automagic?) imports of plots/graphics. Thanks in advance and best regards, Eduardo de Oliveira Horta [[alternative HTML version de

[R] Two time measures

2010-11-27 Thread Eduardo de Oliveira Horta
Hello! I have a csv file of intra-day financial data (5-min closing prices) that looks like this: (obs - the dates are formated as day/month/year, as is usual here in Brazil) Date;Time;Close 01/09/2009;10:00;56567 01/09/2009;10:05;56463 01/09/2009;10:10;56370 ##(goes on all day) 01/09/2009;16:45;

[R] On efficiency, Vectorize and loops

2010-11-17 Thread Eduardo de Oliveira Horta
In my last e-mails, I have asked for help regarding 1. 'defining functions inside loops' 2. 'integrating functions / vector arithmetics' 3. 'vectors out of lists?' 4. 'numerical integration' Since some of these topics seemed to be relevant (I'm guessing by the # of replies I got), I'm posting a mo

[R] Fwd: Numerical integration

2010-11-17 Thread Eduardo de Oliveira Horta
-- Forwarded message -- From: Eduardo de Oliveira Horta Date: Wed, Nov 17, 2010 at 3:59 PM Subject: Re: [R] Numerical integration To: David Winsemius It works, however is not very efficient for the problem I'm working with, since it is the same as vectorizing the inte

Re: [R] Vectors out of lists?

2010-11-17 Thread Eduardo de Oliveira Horta
u) > for(Yi in Y[-1]) result <- result + Yi(u) > result/length(Y) > } > > You could probably shoehorn this into a call to Reduce but there > must be a for loop in Reduce. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > &g

[R] Numerical integration

2010-11-17 Thread Eduardo de Oliveira Horta
Hi! I was wondering if there are any other functions for numerical integration, besides 'integrate' from the stats package, but which wouldn't require the integrand to be vectorized. Oh, and must be capable of integrating over (-inf,+inf). Thanks in advance, Eduardo Horta [[alternative

Re: [R] Vectors out of lists?

2010-11-16 Thread Eduardo de Oliveira Horta
UC Berkeley > spec...@stat.berkeley.edu > > > > > On Tue, 16 Nov 2010, Eduardo de Oliveira Horta wrote: > > Thanks, guys... but it seems these suggestions won't work. >> >> Let me try to be more specific with a simple ex

Re: [R] Vectors out of lists?

2010-11-16 Thread Eduardo de Oliveira Horta
Thanks, guys... but it seems these suggestions won't work. Let me try to be more specific with a simple example: Y<-list() Y[[1]]<-function(u) sqrt(u) Y[[2]]<-function(u) sin(u) Y[[3]]<-function(u) 1/2*u I wanted something equivalent to Ybar<-function(u){ 1/3*(Y[[1]](u) + Y[[2]](u) + Y[[3]](

[R] Vectors out of lists?

2010-11-16 Thread Eduardo de Oliveira Horta
Hello there I have a list, Y, and each component of that list is a real-valued function (that is, Y[[i]](u) returns a number). I was wishing to build the mean function and the first thing I thought of was Ybar<-function(u){ mean(Y[[1:n]](u)) } but obviously this doesn't work, since Y[[1:n]]

Re: [R] Integrating functions / vector arithmetic

2010-11-16 Thread Eduardo de Oliveira Horta
)(u)) > > } > > f > > } > > > > If you only want the inner product of 2 vector, "outer" probably is an > overkill. > > g <- function(u){ > sum(coeff * zeta(1:4)(u)) > } > > should be enough. > > And plot(g) does not work

Re: [R] Integrating functions / vector arithmetic

2010-11-15 Thread Eduardo de Oliveira Horta
Thanks! Seems to work just fine! Best regards, Eduardo Horta On Mon, Nov 15, 2010 at 10:37 PM, David Winsemius wrote: > > On Nov 15, 2010, at 7:18 PM, Eduardo de Oliveira Horta wrote: > > Hello, >> >> I was trying to build some functions which I would like to integrat

[R] Integrating functions / vector arithmetic

2010-11-15 Thread Eduardo de Oliveira Horta
Hello, I was trying to build some functions which I would like to integrate over an interval using the function 'integrate' from the 'stats' package. As an example, please consider the function h(u)=sin(pi*u) + sqrt(2)*sin(pi*2*u) + sqrt(3)*sin(pi*3*u) + 2*sin(pi*4*u) Two alternative ways to 'bu

Re: [R] Defining functions inside loops

2010-11-15 Thread Eduardo de Oliveira Horta
t; wdunlap tibco.com > > > -Original Message----- > > From: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-project.org] On Behalf Of Eduardo de > > Oliveira Horta > > Sent: Monday, November 15, 2010 12:50 PM > > To: r-help@r-project.org &g

[R] Defining functions inside loops

2010-11-15 Thread Eduardo de Oliveira Horta
Hello, I was trying to define a set of functions inside a loop, with the loop index working as a parameter for each function. Below I post a simpler example, as to illustrate what I was intending: f<-list() for (i in 1:10){ f[[i]]<-function(t){ f[[i]]<-t^2+i } } rm(i) With that, I was ex