Re: [R] How to set the scale of axis?

2007-04-06 Thread Gabor Grothendieck
Try this: plot(1:100, xaxt = "n") axis(1, c(1, 20, 40, 60, 80, 100)) # and optionally add this third line axis(1, 1:100, FALSE, tcl = -0.3) See ?par (for the xaxt argument to plot) and ?axis . ?plot and ?plot.default have info on the plot command. A good source of sample code for graphics is:

Re: [R] lm() intercept at the end, rather than at the beginning

2007-04-05 Thread Gabor Grothendieck
Try this. It captures the output of x and sets idx to the line numbers of the coefficients, rearranging their order in the next line and printing them out in the line after that. my.print.summary.lm <- function(x, ...) { out <- capture.output(x) idx <- seq(grep("Intercept", out),

Re: [R] Extent of time zone vulerability for POSIX date and time classes

2007-04-05 Thread Gabor Grothendieck
know of a format > convention that gets it back to numeric (although conventions are > documented for forcing to character). Comment? > > Regards, > > Tim. > > > Gabor Grothendieck wrote: > > If you use > > > > Sys.putenv(TZ = "GMT") > > > >

Re: [R] Extent of time zone vulerability for POSIX date and time classes

2007-04-05 Thread Gabor Grothendieck
If you use Sys.putenv(TZ = "GMT") at the beginning of your session then local time zone and GMT time zone will be the same so you should not have a problem. This was not possible, at least on Windows, at the time the R News article was written. On 4/5/07, Tim Bergsma <[EMAIL PROTECTED]> wro

Re: [R] Plotting multiple curves with lattice graphs

2007-04-05 Thread Gabor Grothendieck
Try this: x <- 1:100 xyplot(dnorm(x, 50, 10) + dnorm(x, 55, 12) + dnorm(x, 60, 15) ~ x, type = "l") By the way, you can save classic graphics, at least on windows, like this: ### your code parms <- data.frame(ID=c(1,2,3),mu=c(50,55,60),sigma=c(10,12,15)) curve(dnorm(x,mean=parms$mu[1],sd=parms$s

Re: [R] clear console

2007-04-05 Thread Gabor Grothendieck
Check out: http://tolstoy.newcastle.edu.au/R/help/06/02/21634.html On 4/5/07, Robert McFadden <[EMAIL PROTECTED]> wrote: > Hi R Users, > > In Windows I can clear console using CTRL-L, but can I do this by certain > command in my programs? e.g > > for (i in 1:10){ > > something > > clear conso

Re: [R] Strange labels on plot with dates

2007-04-03 Thread Gabor Grothendieck
What version of R are you using? When I copy and paste that into R 2.4.1 on Windows XP I get 2001, 2002, ..., 2007 On 4/3/07, Henrik Andersson <[EMAIL PROTECTED]> wrote: > Hello fellow R people, > > I don't understand the default behavior of the axis labeling when > plotting dates. > > I would ex

Re: [R] Create a new var reflecting the order of subjects in existing var

2007-04-02 Thread Gabor Grothendieck
e: Run Length Endcoding > > dat$IDorder1 <- unlist(sapply(y$lengths, FUN=function(x) seq(1,x))) > > dat > > > > # 2st (by Chaliraos Skiadas) > > dat$IDorder2 <- unlist(tapply(dat$ID,factor(dat$ID), function(x) > > 1:length(x)),use.names=FALSE) > >

Re: [R] Create a new var reflecting the order of subjects in existing var

2007-04-01 Thread Gabor Grothendieck
Assuming the ID's are contiguous, as in your example: transform(dat, IDorder = seq(ID) - match(ID, ID) + 1) On 4/1/07, Nguyen Dinh Nguyen <[EMAIL PROTECTED]> wrote: > Dear R helpers > I have a data set sth like this: > set.seed(123);dat <- data.frame(ID= c(rep(1,2),rep(2,3), rep(3,3), rep(4,4

Re: [R] line endings in lattice plots: square vs. round

2007-04-01 Thread Gabor Grothendieck
See gpar in grid: library(grid) ?gpar library(lattice) xyplot(rivers ~ rivers, type = "l", lwd = 10, lineend = 1) On 4/1/07, John Bullock <[EMAIL PROTECTED]> wrote: > > I would like to use llines() to draw lines with > square endings in lattice plots. But the default > behavior seems to be to d

Re: [R] adding slashes in sql querys

2007-04-01 Thread Gabor Grothendieck
On 4/1/07, Laurent Valdes <[EMAIL PROTECTED]> wrote: > Hi everybody, > > really sorry !!! > this is RODBC indeed. But I'm not sure if the package or R version makes a > real difference. > In fact, I used fast=FALSE, and I'm now pretty sure the error is due to that > parameter. > It may be working f

Re: [R] Help in getting aggregated data

2007-03-31 Thread Gabor Grothendieck
Try this: aggregate(a[3], a[1:2], max) On 3/31/07, Deepak Manohar <[EMAIL PROTECTED]> wrote: > Hi team, > I have the data of the form: > > > a<- data.frame(x=c(1,2,1,4,3), y=c(1,2,1,4,3), z=c(1,2,3,4,5)) > > I need the output of the form > > > b<- data.frame(x=c(1,2,3,4), y=c(1,2,3,4), z=(3,2,

Re: [R] plotting POSIXct objects {was Re: Using split() several times in a row?}

2007-03-31 Thread Gabor Grothendieck
= Plot 2 === > # system TZ is in "Pacific Daylight Time" > # POSIXct object is in "GMT" > dp <- seq(Sys.time(),len=10,by="day") > plot(as.POSIXct(format(dp),"GMT"),1:length(dp)) > # Shifted by 7 hours > > #=== Plot 3 === > #

Re: [R] Using split() several times in a row?

2007-03-31 Thread Gabor Grothendieck
On 3/31/07, Martin Maechler <[EMAIL PROTECTED]> wrote: > >>>>> "SteT" == Stephen Tucker <[EMAIL PROTECTED]> > >>>>> on Fri, 30 Mar 2007 18:41:39 -0700 (PDT) writes: > > [..] > >SteT> For dates, I usually store th

Re: [R] adding slashes in sql querys

2007-03-31 Thread Gabor Grothendieck
Try this: 'my dog named "Spot" and my cat named "Kitty" fight like cats and dogs' On 3/31/07, Laurent Valdes <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I'm doing a sqlSave() in R, to insert a big data frame of 1 rows. > However, there is problems, since several rows contains quotations ma

Re: [R] substitute NA values

2007-03-30 Thread Gabor Grothendieck
ot;, NA, "d", "e")), stringsAsFactors = FALSE) DF$a <- factor(DF$a) DF$c <- factor(DF$c) DF <- na.roughfix(DF) DF$c <- as.character(DF$c) DF On 3/30/07, Sergio Della Franca <[EMAIL PROTECTED]> wrote: > This is that i obtained. > > There isn't

Re: [R] substitute NA values

2007-03-30 Thread Gabor Grothendieck
I assume you are referring to na.roughfix in randomForest. I don't think it works for logical vectors or for factors outside of data frames: > library(randomForest) > DF <- data.frame(a = c(T, F, T, NA, T), b = c(1:3, NA, 5)) > na.roughfix(DF) Error in na.roughfix.data.frame(DF) : na.roughfix onl

Re: [R] ccf time units

2007-03-29 Thread Gabor Grothendieck
The unit of time for a "ts" class object is deltat(ldeaths). See the ?deltat help page. On 3/29/07, tom soyer <[EMAIL PROTECTED]> wrote: > Hi, > > I am using ccf but I could not figure out how to calculate the actual lag in > number of periods from the returned results. The documentation for cc

Re: [R] aggregating data with Zoo

2007-03-28 Thread Gabor Grothendieck
Please read the last line on every post to r-help. On 3/28/07, Alfonso Sammassimo <[EMAIL PROTECTED]> wrote: > Is there a way of aggregating 'zoo' daily data according to day of week? eg > all Thursdays > > I came across the 'nextfri' function in the documentation but am unsure how > to change thi

Re: [R] Help with grep (and similar functions)

2007-03-28 Thread Gabor Grothendieck
Try this: library(gsubfn) pat <- "([[:upper:]][[:lower:]]*) " s <- "Aaaa 3 x 0 Bbbb" strapply(s, pat, backref =-1)[[1]] or (not quite as general but works in this case): pat <- "([[:upper:]][[:lower:]]*) " s <- "Aaaa 3 x 0 Bbbb" s.idx <- gregexpr(pat, s)[[1]] substring(s, s.idx, s.idx + attr(s

Re: [R] regarding time series object

2007-03-28 Thread Gabor Grothendieck
I am not 100% sure of what you want but maybe this will help. I have modified your example data to omit one point so that there is a holiday among the rows: library(zoo) # read data Lines <- "DateOpenHigh Low CloseNifty 2004-01-01 1880.35 1917.05 1880.351912.25 2004-01-02 1912.25

Re: [R] Replacement in an expression - can't use parse()

2007-03-28 Thread Gabor Grothendieck
The solution in my post has the advantage of not using eval or character conversions (except in setting up L where you want such character conversions to build up the names, as your more general sitution shows). The following is the same as in that post except the line setting L in that post is re

Re: [R] line style outliers in boxplot

2007-03-27 Thread Gabor Grothendieck
As indicated in ?boxplot it passes certain arguments to bxp so check out ?bxp where you will find various out... arguments: boxplot(c(1:10, 20), outlty = 2, outcex = 0 ) On 3/27/07, AA <[EMAIL PROTECTED]> wrote: > Dear Users > > Is there any way to generate lines instead of points for outliers i

Re: [R] Replacement in an expression - can't use parse()

2007-03-27 Thread Gabor Grothendieck
Try substitute: e <- expression(u1 + u2 + u3) L <- list(u2 = as.name("x"), u3 = 1) as.expression(do.call(substitute, list(as.call(e), L))[[1]]) On 3/27/07, Daniel Berg <[EMAIL PROTECTED]> wrote: > Dear all, > > Suppose I have a very long expression e. Lets assume, for simplicity, that it > is >

Re: [R] Prefered date and date/time classes

2007-03-27 Thread Gabor Grothendieck
On 3/27/07, Charles Dupont <[EMAIL PROTECTED]> wrote: > What are the preferred date, and data/time classes for R? See the help desk article in R News 4/1. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do re

Re: [R] Updating a worksheet in Excel file using RODBC

2007-03-26 Thread Gabor Grothendieck
You could use RDCOMClient or rcom packages to update an Excel spreadsheet in place and you would not need any VBA at all. Search through the archives for the keyword Excel.Application . On 3/27/07, Moshe Olshansky <[EMAIL PROTECTED]> wrote: > OK. > > By the way, I only thought that I could do wh

Re: [R] a very small query

2007-03-26 Thread Gabor Grothendieck
Try these: search() sessionInfo() loadedNamespaces() The first two show the attached packages (and some other info) and the last one shows the namespaces that are loaded. Note that detaching a package does not unload its namespace and unloading a namespace does not de-register its methods. This

Re: [R] eliminating panel borders from lattice plots

2007-03-25 Thread Gabor Grothendieck
Try adding this argument to your xyplot call: par.settings = list(axis.line = list(col = 0)) The subparameters oif axis.line are: trellis.par.get()$axis.line in case you want to temporarily set others. On 3/25/07, John Bullock <[EMAIL PROTECTED]> wrote: > > I am trying to eliminate panel

Re: [R] Two Problems while trying to aggregate a dataframe

2007-03-24 Thread Gabor Grothendieck
Try this: aggregate(atest[3:4], atest[1:2], sum) Use a data base and SQL is you don't otherwise have enough computer resources. On 3/24/07, Delcour Libertus <[EMAIL PROTECTED]> wrote: > Hello! > > Given is an Excel-Sheet with actually 11,000 rows and 9 columns. I want > to work with the data in

Re: [R] Conversion from string to date type

2007-03-23 Thread Gabor Grothendieck
Read the help desk article in R-News 4/1 and see ?as.Date ?strptime (for setting the as.Date format= argument) Also, you might be interested in the zoo package library(zoo) ?read.zoo vignette("zoo") vignette("zoo-quickref") On 3/23/07, Andreas Tille <[EMAIL PROTECTED]> wrote: > Hi, > > I'm on

Re: [R] Get "home" directory and simple I/O

2007-03-23 Thread Gabor Grothendieck
path.expand("~") also seems to work on Windows XP. On 3/23/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > But the request was for a *generic* solution. On Windows there > might not be anything corresponding to a home directory (and the rw-FAQ > discusses the concept and how R resolves this).

Re: [R] Get "home" directory and simple I/O

2007-03-23 Thread Gabor Grothendieck
On 3/23/07, Liaw, Andy <[EMAIL PROTECTED]> wrote: > From: Gabor Grothendieck > > > > See: > > > > ?R.home > > That's not what Alberto wanted: It gives the location of the R > installation, not where user's home directory is. AFAIK Windows doe

Re: [R] Get "home" directory and simple I/O

2007-03-23 Thread Gabor Grothendieck
See: ?R.home ?dput On 3/23/07, Alberto Monteiro <[EMAIL PROTECTED]> wrote: > Is there any generic function that gets the "home" directory? This > should return /home/ in Linux and > x:/Documents and Settings/ (or whatever) in Windows XP. > > Another (unrelated) question: what is the _simplest_ wa

Re: [R] Effect display of proportional odds model

2007-03-23 Thread Gabor Grothendieck
Looks like there is code in the appendix. On 3/23/07, Jan Wijffels <[EMAIL PROTECTED]> wrote: > Dear useRs, > I very much like the effect display of the proportional odds model on > page 29 (Figure 8) of the following paper by John Fox: > http://socserv.mcmaster.ca/jfox/Papers/logit-effect-display

Re: [R] quick legend() question

2007-03-22 Thread Gabor Grothendieck
Try pt.lwd= instead of lwd= in your legend call. On 3/22/07, Robin Hankin <[EMAIL PROTECTED]> wrote: > Hi > > I have a scatterplot of points with pch=1 and a single point with > pch=3, lwd=3. > It has a high line width to attract attention to it. > > The following script > > > > plot(rnorm(10),rno

Re: [R] "digits" doesn't work in format function

2007-03-22 Thread Gabor Grothendieck
Try sprintf("%.2f", m) On 3/22/07, Baoqiang Cao <[EMAIL PROTECTED]> wrote: > Dear All, > > I was trying to format a numeric vector (100*1) by using > outd <- format(x=m, sci=F, digits=2) > > > outd[1:10] > [1] " 0.01787758" "-0.14760306" "-0.45806041" "-0.67858525" "-0.64591748" > [6] "-0.0591

Re: [R] dynamic linear models in R

2007-03-22 Thread Gabor Grothendieck
Package dynlm (and dyn) are used to align the time series in the dependent and independent portions of the equations so that one can perform regressions on lagged and differenced versions of the dependent and independent variables. They compensate for the fact that lm (and in the case of dyn lm, gl

Re: [R] Over-writing functions from other packages? What is a good strategy??

2007-03-21 Thread Gabor Grothendieck
Sometimes but its also easy to forget about simple solutions. On 3/21/07, Alberto Monteiro <[EMAIL PROTECTED]> wrote: > Gabor Grothendieck wrote: > > > > Could you call yours Edges? > > > Is it a good idea to have two different functions, whose name > differs by

Re: [R] Over-writing functions from other packages? What is a good strategy??

2007-03-20 Thread Gabor Grothendieck
Could you call yours Edges? On 3/20/07, Søren Højsgaard <[EMAIL PROTECTED]> wrote: > I am writing a package which uses the Rgraphviz package which in turn uses > the graph package, but my question does not (I believe) pertain specifically > to the these packages so therefore I dare to post the q

Re: [R] Problems about Derivaties

2007-03-20 Thread Gabor Grothendieck
On 3/20/07, enrico.foscolo <[EMAIL PROTECTED]> wrote: > Dear participants to the list, > > this is my problem: I want to obtain an expression that represents the second > derivative of one function. > With "deriv3" (package "stats") it is possible to evaluate the second > derivative, but I do not k

Re: [R] Hardware for a new Workstation for best performance using R

2007-03-19 Thread Gabor Grothendieck
Along the lines you mention, check out: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/32297.html On 3/19/07, Dalphin, Mark <[EMAIL PROTECTED]> wrote: > On Mon, 19 Mar 2007, Thomas Lumley wrote: > >> On 3/19/07, Thomas Lumley <[EMAIL PROTECTED]> wrote: > >>> On Thu, 15 Mar 2007, Andrew Perrin wr

Re: [R] Hardware for a new Workstation for best performance using R

2007-03-19 Thread Gabor Grothendieck
I think there are a lot of misconceptions regarding what is possible on Windows. On Windows you just right click the graphic in R and choose Copy as Metafile which puts a vector graphic representation on the clipboard and then ctrl-V in Word to copy it in. (Alternately save all your graphics as f

Re: [R] Hardware for a new Workstation for best performance using R

2007-03-19 Thread Gabor Grothendieck
On 3/19/07, Thomas Lumley <[EMAIL PROTECTED]> wrote: > On Mon, 19 Mar 2007, Gabor Grothendieck wrote: > > > On 3/19/07, Thomas Lumley <[EMAIL PROTECTED]> wrote: > >> On Thu, 15 Mar 2007, Andrew Perrin wrote: (in part) > >>> > >>> 2.) Yes,

Re: [R] Hardware for a new Workstation for best performance using R

2007-03-19 Thread Gabor Grothendieck
On 3/19/07, Marc Schwartz <[EMAIL PROTECTED]> wrote: > On Mon, 2007-03-19 at 11:43 -0400, Gabor Grothendieck wrote: > > On 3/19/07, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > > On Thu, 15 Mar 2007, Andrew Perrin wrote: (in part) > > > > > > > &

Re: [R] Hardware for a new Workstation for best performance using R

2007-03-19 Thread Gabor Grothendieck
On 3/19/07, Thomas Lumley <[EMAIL PROTECTED]> wrote: > On Thu, 15 Mar 2007, Andrew Perrin wrote: (in part) > > > > 2.) Yes, by all means you should use linux instead of windows. The > > graphics output is completely compatible with whatever applications you > > want to paste them into on Windows. >

Re: [R] character to numeric conversion

2007-03-19 Thread Gabor Grothendieck
Here is one way. This matches strings which contain those characters found in a number, converting each such string to numeric. library(gsubfn) strapply(x, "[-0-9+.E]+", as.numeric) On 3/19/07, Robin Hankin <[EMAIL PROTECTED]> wrote: > Hi. > > Is there a straightforward way to convert a charact

Re: [R] any simple way to put comment with multiple lines

2007-03-18 Thread Gabor Grothendieck
You could do this: f <- function(x) { "This is some text that I would like to have here." x + 1 } f(2) # 3 On 3/18/07, Wensui Liu <[EMAIL PROTECTED]> wrote: > Dear Lister, > I understand I can put '#' to put comment line by line. But is there a > way to put comment with multiple lines without ha

Re: [R] italics letter in roman string

2007-03-18 Thread Gabor Grothendieck
ng needed to > be within quotes. What is happening here, exactly? Why the use of > "~"? I tried without and it no longer works. > > Thanks in advance, > > Denis > Le 07-03-18 à 08:59, Gabor Grothendieck a écrit : > > > Sorry, legend= was omitted: > >

Re: [R] italics letter in roman string

2007-03-18 Thread Gabor Grothendieck
Sorry, legend= was omitted: plot(1:10) legend("topleft", legend = This ~ study ~ italic(n) == 3293) On 3/18/07, Chabot Denis <[EMAIL PROTECTED]> wrote: > Thank you Marc, Jim and Gabor, > > I like the solution with "expression", nice and simple. Gabor, your > solution did not work, probably just a

Re: [R] italics letter in roman string

2007-03-17 Thread Gabor Grothendieck
Try this: plot(1:10) legend("topleft", This ~ study ~ italic(n) == 3293) On 3/17/07, Chabot Denis <[EMAIL PROTECTED]> wrote: > Hi, > > As part of the legend to a plot, I need to have the "n" in italics > because it is a requirement of the journal I aim to publish in: > "This study, n = 3293" > >

Re: [R] Revisiting multiple plots

2007-03-16 Thread Gabor Grothendieck
Try this (or use xyplot.zoo and write a panel function for that): library(zoo) set.seed(1) tt <- as.Date(paste(2004, rep(1:2, 5), sample(28, 10), sep = "-")) foo <- zoo(matrix(rnorm(100), 10), tt) pnl <- function(x, y, ...) { lines(x, y, ...) abline(h = mean(y)) } plot(foo, panel

Re: [R] Implementing trees in R

2007-03-16 Thread Gabor Grothendieck
On 3/16/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > 1. Here is your example redone using proto: > > library(proto) > > parent <- proto() > child <- proto(a = 1) > parent$child1 <- child > child$parent.env <- parent This last line should have been:

Re: [R] Implementing trees in R

2007-03-16 Thread Gabor Grothendieck
ode object type with a > default behavior for the "<-" operator of its member variables being > referencing rather than copying? Any good reference material/ similar > code examples? > >Thanks. > > Gabor Grothendieck wrote: > > Lists are not good for this. Th

Re: [R] Implementing trees in R

2007-03-16 Thread Gabor Grothendieck
it via references as requested then lists are not appropriate. On 3/16/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Lists are not good for this. There is an example in section 3.3 of > the proto vignette of using proto objects for this. That section > also references an S4 e

Re: [R] Implementing trees in R

2007-03-16 Thread Gabor Grothendieck
Lists are not good for this. There is an example in section 3.3 of the proto vignette of using proto objects for this. That section also references an S4 example although its pretty messy with S4. You might want to look at the graph, RBGL and graphviz packages in Bioconductor and the dynamicgrap

Re: [R] timeDate & business day

2007-03-12 Thread Gabor Grothendieck
Regarding time series manipulation in R you could read the two vignettes that come with the zoo package: library(zoo) vignette("zoo") vignette("zoo-quickref") Note that zoo is an entirely different system than rmetrics and timeDate so if your question is specifically aimed at timeDate this does n

Re: [R] Mac vs. PC

2007-03-10 Thread Gabor Grothendieck
Such a calculation would be dominated by the time spent inside a call to an offf-the-shelf C matrix inversion library used by R and is not really any test of R itself. On 3/9/07, Richard Morey <[EMAIL PROTECTED]> wrote: > My adviser has a Mac notebook that he bought 6 months ago, and I have a > PC

Re: [R] piecing together statements (macro?)

2007-03-10 Thread Gabor Grothendieck
Read the FAQ 7.21: http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f Note that it points out that you don't really want to do this anyways. On 3/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi All > > I am pretty new to R but saw stata and sas's

Re: [R] Using large datasets: can I overload the subscript operator?

2007-03-10 Thread Gabor Grothendieck
On 3/9/07, Maciej Radziejewski <[EMAIL PROTECTED]> wrote: > Hello, > > I do some computations on datasets that come from climate models. These data > are huge arrays, significantly larger than typically available RAM, so they > have to be accessed row-by-row, or rather slice-by slice, depending on

Re: [R] Extracting text from a character string

2007-03-09 Thread Gabor Grothendieck
Try this: library(gsubfn) x <- "CB01_0171_03-27-2002-(Sample 26609)-(126)" unlist(strapply(x, "..-..-")) The gsubfn home page is at: http://code.google.com/p/gsubfn/ On 3/9/07, Shawn Way <[EMAIL PROTECTED]> wrote: > I have a set of character strings like below: > > > data3[1] > [1] "CB01_01

Re: [R] sending a vector of characters as arguments for a function

2007-03-08 Thread Gabor Grothendieck
Try this: C1 <- 1:3 C2 <- 4:6 sapply(ls(pattern = "C"), get) On 3/8/07, BOISSON, Pascal <[EMAIL PROTECTED]> wrote: > Dear all, > > > > It seems to be a recurrent problem to me and I am asking your help to > get over it once for all ... > > > > My idea is : > > > > I have variables C_1, C_2, C_3 .

Re: [R] chronological scatterplots

2007-03-08 Thread Gabor Grothendieck
Read R News 4/1 help desk article about dates. Also see ?as.yearmon in the zoo package. > library(zoo) > dd <- Sys.Date() + seq(1, 1000, 100) > dd [1] "2007-03-09" "2007-06-17" "2007-09-25" "2008-01-03" "2008-04-12" [6] "2008-07-21" "2008-10-29" "2009-02-06" "2009-05-17" "2009-08-25" > ym <- as

Re: [R] Named backreferences in replacement patterns

2007-03-08 Thread Gabor Grothendieck
Sorry. An extra line got in there. It should have been: library(gsubfn) gsubfn("(?\\d+)/(?\\d+)/", month + day ~ sprintf("%s/%s/", day, month), backref = -2, British.dates, perl = TRUE) On 3/8/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > This does n

Re: [R] Named backreferences in replacement patterns

2007-03-08 Thread Gabor Grothendieck
This does not really answer the specific question you posted but gsubfn can do it without using \\1 and \\2 like this (you probably realized that already but I thought I would point it out just in case): library(gsubfn) gsubfn("(?\\d+)/(?\\d+)/", month + day ~ sprintf("%s/%s/", day, month),

Re: [R] how to avoid to overwrite object

2007-03-07 Thread Gabor Grothendieck
Decompose your code into small understandable functions. On 3/7/07, Aimin Yan <[EMAIL PROTECTED]> wrote: > Dear R list, > I have a question in R, it could be very simple, but I don't know how to do > it? > > for example: > I assign 6 to x in beginning of of my R script code > > x<-6 > .. > A

Re: [R] Autogenerate tags in tag=value pairs for

2007-03-07 Thread Gabor Grothendieck
Try na.locf from the zoo package and then use merge with specified suffixes: library(zoo) f <- function(x) { rownames(x) <- NULL merge(x, na.locf(x[-1], na.rm = FALSE), by = 0, suffixes = c("", ".by"))[-1] } do.call("rbind", by(x, x$id, f)) On 3/7/07, Jon Olav Vik <[EMAIL PROTECTED]> wrote

Re: [R] optim(), nlminb() and starting values

2007-03-06 Thread Gabor Grothendieck
If your problem is small enough just use a grid of starting values and run your optimization on each one and then take the best. On 3/6/07, Dae-Jin Lee <[EMAIL PROTECTED]> wrote: > Hi all ! > > I've been trying to maximize a likelihood using optim( ) function, but it > seems that the function has

Re: [R] R software to place points on Yahoo maps

2007-03-04 Thread Gabor Grothendieck
Hi, Your response to my post was EXTREMELY useful. For georegistering I used the site: http://www.runningmap.com which lets one click on a a Yahoo! map and get lat/long in lower right. As my data is in UTM I converted the lat/long to UTM using: http://home.hiwaay.net/~taylorc/toolbox/geog

[R] R software to place points on Yahoo maps

2007-03-03 Thread Gabor Grothendieck
Is there any R software that create an image from Yahoo maps together with points of known UTM coordinates (or lat/long marked? Note that my region of interest is not covered in sufficient detail by Google maps. It actually does not have to be Yahoo maps as long as it has sufficient coverage of my

Re: [R] Fwd: Re: [friday topic]: what exactly is statistical com

2007-03-02 Thread Gabor Grothendieck
On 3/2/07, Ted Harding <[EMAIL PROTECTED]> wrote: > I think the first developments which could be recognised as > "statistical cmputing" (as opposed to using computers to do > statistics) were the pioneering GENSTAT and GLIM (1973-4, > though developed over some years previously). Possibly > what

Re: [R] nlm() problem : extra parameters

2007-03-02 Thread Gabor Grothendieck
Change the name of n to something else. Also please using spacing in your code for readability. > x <- c(10.2, 7.7, 5.1, 3.8, 2.6) > y <- c(9, 8, 3, 2, 1) > n. <- c(10, 9, 6, 8, 10) > > > derfs4 <- function(b, x, y, n.) + { + b0 <- b[1] + b1 <- b[2] + c=b0 +b1 * x +

Re: [R] plot with fixed axis proportion

2007-03-02 Thread Gabor Grothendieck
See the aspect argument, asp, in ?plot.default . Also eqscplot in MASS. On 3/2/07, Thomas Steiner <[EMAIL PROTECTED]> wrote: > I want to plot something (eg a circle) with a fixed ratio of the x and > y axis, or (even better) with a fixed size when I print it. Output > should then be a circle (act

Re: [R] from function to its name?

2007-03-02 Thread Gabor Grothendieck
Check out: https://stat.ethz.ch/pipermail/r-help/2006-October/114431.html On 3/2/07, Ido M. Tamir <[EMAIL PROTECTED]> wrote: > Charilaos Skiadas wrote: > > > On Mar 2, 2007, at 9:42 AM, Ido M. Tamir wrote: > >> > >> But how do I get from a function to its name? > > > > Can you do this with any ob

Re: [R] extracting data from zoo series

2007-03-02 Thread Gabor Grothendieck
Please read the last line of every message to r-help and follow it when posting. You ought to have provided small examples for A and B and the result. The following lists every row in z that is at a date in zs or is up to 4 rows later: library(zoo) z <- zoo(matrix(101:148, 24), 2001:2024) zs <-

Re: [R] Error in length of vector ?

2007-03-02 Thread Gabor Grothendieck
Suggest you review the help desk article on dates in R News 4/1. It mentions that POSIXlt objects are lists with 9 components and other facts about date objects in R. On 3/2/07, Sérgio Nunes <[EMAIL PROTECTED]> wrote: > Hi, > > I'm having a weird result with the length() function: > > >a > [...

Re: [R] plot of 2 time series with very different values

2007-03-02 Thread Gabor Grothendieck
There is an example in the example section of plotting two time series on the same plot with different left hand and right hand scales here: library(zoo) ?plot.zoo On 3/2/07, Berta <[EMAIL PROTECTED]> wrote: > > Hi R-Users, > > I am trying to plot two time series in the same plot, but they measur

Re: [R] FTP download from ftp.sec.gov

2007-03-01 Thread Gabor Grothendieck
On Windows XP it worked for me on both 2.4.1 and 2.5.0. I did notice that on 2.4.1 it says "using Synchronous WinInet calls" but does not say this on 2.5.0. See below for the two transcripts. > ftp <- "ftp://anonymous:[EMAIL PROTECTED]/edgar/full-index/company.idx" > download.file(url=ftp, destf

Re: [R] How to read in this data format?

2007-03-01 Thread Gabor Grothendieck
On 3/1/07, Bart Joosen <[EMAIL PROTECTED]> wrote: > Dear All, > > thanks for the replies, Jim Holtman has given a solution which fits my > needs, but Gabor Grothendieck did the same thing, > but it looks like the coding will allow faster processing (should check this &g

Re: [R] How to read in this data format?

2007-03-01 Thread Gabor Grothendieck
Read in the data using readLines, extract out all desired lines (namely those containing only numbers, dots and spaces or those with the word Time) and remove Retention from all lines so that all remaining lines have two fields. Now that we have desired lines and all lines have two fields read the

Re: [R] What is a expression good for?

2007-02-28 Thread Gabor Grothendieck
You can evaluate it, differentiate it, pick apart its components, use it as a title or legend in a plot, use it as a function body and probably other things too: e <- expression(x+y) eval(e, list(x = 1, y = 2)) # 3 D(e, "x") e[[1]][[1]] # + e[[1]][[2]] # x e[[1]][[3]] # y plot(1:10, main = e)

Re: [R] Packages in R for least median squares regression and computing outliers (thompson tau technique etc.)

2007-02-28 Thread Gabor Grothendieck
Try rq in quantreg using the default value for tau. On 2/28/07, lalitha viswanath <[EMAIL PROTECTED]> wrote: > Hi > I am looking for suitable packages in R that do > regression analyses using least median squares method > (or better). Additionally, I am also looking for > packages that implement a

Re: [R] Macros in R

2007-02-27 Thread Gabor Grothendieck
The FAQ does mention your point already. On 2/27/07, Greg Snow <[EMAIL PROTECTED]> wrote: > Others have pointed you to the answer to your question, but both FAQ > 7.21 and the assign help page should really have a big banner at the top > saying "Here Be Dragons". > > Using a loop or other automate

Re: [R] ts; decompose; plot and title

2007-02-27 Thread Gabor Grothendieck
Try this: plot(cbind(observed = z$random + z$trend * z$seasonal, trend = z$trend, seasonal = z$seasonal, random = z$random), main = "My title") Change the * to + if your setup is additive. On 2/27/07, Alberto Monteiro <[EMAIL PROTECTED]> wrote: > Is there any way to give a "decent" t

Re: [R] PLotting R graphics/symbols without user x-y scaling

2007-02-26 Thread Gabor Grothendieck
You can use par("usr") to get the min/max coords of the plot and then use that. For example, this will plot a red dot in the middle of the plot area regardless of the coordinates: plot(1:10) # sample plot usr <- par("usr") points(mean(usr[1:2]), mean(usr[3:4]), pch = 20, col = "red") # red dot

Re: [R] someattributes

2007-02-26 Thread Gabor Grothendieck
On 2/26/07, Thaden, John J <[EMAIL PROTECTED]> wrote: > I had written > > >> ...someattributes() does not seem to exist. > > And Haris Skiadas replied > > > My help shows it as "moreattributes", not > > "someattributes". (MacOSX), though doesn't > > sound like it should be platform-specific). > > T

Re: [R] Macros in R

2007-02-25 Thread Gabor Grothendieck
Its a FAQ. http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f On 2/25/07, Monika Kerekes <[EMAIL PROTECTED]> wrote: > Dear members, > > > > I have started to work with R recently and there is one thing which I could > not solve so far. I don't know how to de

Re: [R] Double-banger function names: preferences and suggestions

2007-02-25 Thread Gabor Grothendieck
There is a fourth possibility too: 4. `scale colour` I guess my preference is #1, #2, #3 and #4 in that order with #1 best. Even though #1 can conflict with S3 it usually does not and its historically what R used so I usually just stay consistent with historical precedent. #2 is otherwise best

Re: [R] Bold Substring in mtext (newbie question)

2007-02-25 Thread Gabor Grothendieck
Try this: plot(1) mtext(quote(A ~ bold(bold) ~ word), cex = 1.3) On 2/24/07, Joseph Retzer <[EMAIL PROTECTED]> wrote: > Hi everyone, > I suspect this is an easy task however I've not been able to accomplish it. > I'd like to create an mtext title which has certain words bold, the rest not > bo

Re: [R] gsub: replacing a.*a if no occurence of b in .*

2007-02-24 Thread Gabor Grothendieck
parser. So I would double-check > to make sure this doesn't happen. > > Do you have any control on where those XML files are generated > though? It sounds to me it might be easier to fix the utility > generating those XML files, since it clearly is doing something wrong. > &g

Re: [R] gsub: replacing a.*a if no occurence of b in .*

2007-02-24 Thread Gabor Grothendieck
I assume is known. This removes any occurrence .* where .* does not contain or . The regular expression, re, matches , then does a greedy match (?U) for anything followed by but uses a zero width lookahead subexpression (?=...) for the second so that it it can be rematched again. gsubfn in p

Re: [R] Crosstabbing multiple response data

2007-02-22 Thread Gabor Grothendieck
Try this: tab <- crossprod(as.matrix(ratings[,-1])) tab <- tab - diag(diag(tab)) tab tab / nrow(ratings) On 2/22/07, Michael Wexler <[EMAIL PROTECTED]> wrote: > Using R version 2.4.1 (2006-12-18) on Windows, I have a dataset which > resembles this: > > idatt1att2att3 > 11

Re: [R] file path

2007-02-21 Thread Gabor Grothendieck
Its not clear from your post what the framework is that you are working with but assuming that you have sourced a file and want its name place this fn <- parent.frame(2)$ofile # other code in a file a.R, say, and from within R source it: source("a.R") This is not very safe and could eas

Re: [R] help with loop over data frame

2007-02-19 Thread Gabor Grothendieck
Try this: DF[c(FALSE, tail(DF$Open, -1) > head(DF$High, -1)), ] or using zoo objects just compare the Open to the reverse lag of the High. Lines <- "Date Open HighLowClose 1/15/2000 10 11 8 10 1/16/2000 12 12 10 11 1/17/2000 12 12 10

Re: [R] Putting splom in a function

2007-02-15 Thread Gabor Grothendieck
If you call splom with do.call then your solution should work: do.call("splom", list(~data[cols], groups = as.symbol(groups), data = data, panel = panel.superpose, col = colors)) or use as.name where as.symbol is which also works. On 2/14/07, Roberto Perdisci <[EMAIL PROTECTED]> wrote: >

Re: [R] linear coefficient combination stderr?

2007-02-14 Thread Gabor Grothendieck
vcov can simplify it slightly: se <- sqrt( t(a) %*% vcov(m) %*% a ) ( a %*% beta ) / se On 2/14/07, Abhijit Dasgupta <[EMAIL PROTECTED]> wrote: > look at the function "estimable" in the package gmodels. This does the > t.stat that you mention below. > > Otherwise, if you wanted to do this by han

Re: [R] Computing stats on common parts of multiple dataframes

2007-02-13 Thread Gabor Grothendieck
ace(DFs[[1]], TRUE, medians) On 2/13/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Suppose our data frames are called DF1, DF2 and DF3. Then > find the least number of rows, n, among them. Create a > list, DFs, of the last n rows of the data frames and another > list, mats,

Re: [R] Computing stats on common parts of multiple dataframes

2007-02-13 Thread Gabor Grothendieck
Suppose our data frames are called DF1, DF2 and DF3. Then find the least number of rows, n, among them. Create a list, DFs, of the last n rows of the data frames and another list, mats, which is the same but in which each component is a matrix. Create a parallel median function, pmedian, analogo

Re: [R] Advice on visual graph packages

2007-02-13 Thread Gabor Grothendieck
Also try gplot in the sna package to see if it does what you want. Here are some examples from the r-help archives: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/87003.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/84442.html On 2/13/07, Jarrett Byrnes <[EMAIL PROTECTED]> wrote: > Hey,

Re: [R] Missing variable in new dataframe for prediction

2007-02-13 Thread Gabor Grothendieck
Actually this simpler replacement for the b <- ... line would work just as well: fo <- as.formula(sprintf("y ~ s(x0) + s(x1) + ns(%s, 3)", names(Mydata)[i])) b <- gam(fo, data = Mydata) On 2/13/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > The call to library(

Re: [R] Missing variable in new dataframe for prediction

2007-02-13 Thread Gabor Grothendieck
The call to library(splines) is missing and also try replacing the line b <- ... with fo <- as.formula(sprintf("y ~ s(x0) + s(x1) + ns(%s, 3)", names(Mydata)[i])) b <- do.call("gam", list(fo, data = Mydata)) to dynamically recreate the formula on each iteration of the loop with the correct name

<    1   2   3   4   5   6   7   8   9   10   >