[R] Reading multiple files into R
I want to read data from a number of files into R. Reading individual files one by one requires writing enormous amount of code that will look something like the following. maptools:::dbf.read(wb-01vc.dbf)-dist1 maptools:::dbf.read(wb-02vc.dbf)-dist2 maptools:::dbf.read(wb-03vc.dbf)-dist3 maptools:::dbf.read(wb-04vc.dbf)-dist4 maptools:::dbf.read(wb-05vc.dbf)-dist5 maptools:::dbf.read(wb-06vc.dbf)-dist6 maptools:::dbf.read(wb-07vc.dbf)-dist7 maptools:::dbf.read(wb-08vc.dbf)-dist8 maptools:::dbf.read(wb-09vc.dbf)-dist9 * Is there a better way of doing this? Vikas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Can't load rgl library
Hi Thomas, Yes I have the xlibmesa-gl, libglu1-mesa, libglu1-mesa-dev, etc, libraries. But no way. You mentioned TLS (transport Layer Security?), is this OK? I'm working on a Toshiba laptop with graphics driver I852GM Cheers, Antonio -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] nombre de Thomas Schönhoff Enviado el: jueves, 30 de septiembre de 2004 19:16 Para: R User-Liste Asunto: Re: [R] Can't load rgl library Hello, [EMAIL PROTECTED] schrieb: Hi, I've installed rgl package through R CMD INSTALL on a Debian-Sarge machine (PIV) without any compiling error (see attached file), but when trying to load this package within R (and also Rcmdr library) I get: library(rgl) RGL: GLX extension missing on server Error in firstlib(which.lib.loc, package) : error rgl_init error in library(rgl) : .First.lib failed Segmentation fault Same failure problem if I use the apt option (apt-get install r-cran-gl). I've searched through the R mail archives but couldn't find or understand the answer for this problem. I just forgot to say that you also could try to rename /usr/share/tls (IIRC, its tls directory!) to /usr/share/tls_old and re-try loading the package. Maybe default installation doesn't recognize the working drivers, especially if you run NVidia driver on your box! HtH __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html --- Incoming mail is certified Virus Free. --- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Reading multiple files into R
Hi! There is a function ?dir which returns you the content of the dir_ectory. If this is more then there is a function ?grep which allows you to extract relevant items. If you need to postprocess the names you have a function ?paste for example. And finally you have an S language construct for(){} And there is help.search() and An Introduction to R to which tells you how to write functions. /E Vikas Rawal wrote: I want to read data from a number of files into R. Reading individual files one by one requires writing enormous amount of code that will look something like the following. maptools:::dbf.read(wb-01vc.dbf)-dist1 maptools:::dbf.read(wb-02vc.dbf)-dist2 maptools:::dbf.read(wb-03vc.dbf)-dist3 maptools:::dbf.read(wb-04vc.dbf)-dist4 maptools:::dbf.read(wb-05vc.dbf)-dist5 maptools:::dbf.read(wb-06vc.dbf)-dist6 maptools:::dbf.read(wb-07vc.dbf)-dist7 maptools:::dbf.read(wb-08vc.dbf)-dist8 maptools:::dbf.read(wb-09vc.dbf)-dist9 * Is there a better way of doing this? Vikas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dipl. bio-chem. Witold Eryk Wolski MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin _ tel: 0049-30-83875219 'v' http://www.molgen.mpg.de/~wolski / \ mail: [EMAIL PROTECTED] ---W-W [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Reading multiple files into R
On Fri, 1 Oct 2004, Vikas Rawal wrote: I want to read data from a number of files into R. Reading individual files one by one requires writing enormous amount of code that will look something like the following. maptools:::dbf.read(wb-01vc.dbf)-dist1 maptools:::dbf.read(wb-02vc.dbf)-dist2 maptools:::dbf.read(wb-03vc.dbf)-dist3 maptools:::dbf.read(wb-04vc.dbf)-dist4 maptools:::dbf.read(wb-05vc.dbf)-dist5 maptools:::dbf.read(wb-06vc.dbf)-dist6 maptools:::dbf.read(wb-07vc.dbf)-dist7 maptools:::dbf.read(wb-08vc.dbf)-dist8 maptools:::dbf.read(wb-09vc.dbf)-dist9 * In this case, you could pre-allocate a list and: res - vector(mode=list, length=9) for (i in 1:length(res)) res[[i]] - maptools:::dbf.read(paste(wb-0, i, vc.dbf, sep=)) res - vector(mode=list, length=9) for (i in 1:length(res)) cat(paste(wb-0, i, vc.dbf, sep=), \n) wb-01vc.dbf wb-02vc.dbf wb-03vc.dbf ... gives a check on what file names are being used. For 10 to 99 preserving the 01-09, use paste(wb-, formatC(i, width=2, flag=0), vc.dbf, sep=). If the token is a character (string) that varies, you can roll out a character vector of tokens first and step along it. res - vector(mode=list, length=length(LETTERS)) for (i in 1:length(res)) cat(paste(wb-, LETTERS[i], vc.dbf, sep=), + \n) wb-Avc.dbf wb-Bvc.dbf wb-Cvc.dbf ... Is there a better way of doing this? Vikas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] two questions on nlme: error messages and nested variance
Hello: Im hoping the list can shed light on two items. I am using an nlme model to fit a logistic function and have these questions: 1) The model works fine using varIdent(~1|factor) and also using varComb(varIdent(~1|factor),varFixed(~covariate)), but not when varFixed(~covariate) is used alone. Using VarFixed alone gives the message: Error in recalc.varFunc(object[[i]], conLin) : dim- : dims [product 153] do not match the length of object [846] In addition: Warning message: longer object length is not a multiple of shorter object length in: conLin$Xy * varWeights(object). Can anyone shed light on what this message means and how I might go about fixing the problem? I am still new to all this, so please explain with that in mind. 2) In my data, the mean of the variance of the within-group errors is dependent on a covariate, and in addition the variance of the variance is also dependent on a covariate. To model this would one use something like: varIdent(~varIdent(~1|covariate)|covariate)? I get the same error message as above when I try this or if I try: varIdent(~varFixed(~covariate)|factor). Is there a better way to do such nesting? Is it even possible? And again, what does the error mean? Thanks much in advance. John __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Reading multiple files into R
Hoi Vikas, --On vrijdag 1 oktober 2004 10:50 +0530 Vikas Rawal [EMAIL PROTECTED] wrote: I want to read data from a number of files into R. Reading individual files one by one requires writing enormous amount of code that will look something like the following. Is there a better way of doing this? These days I'm using the code below to read in each datafile I have, and come out with a single dataframe. # Concatenate the raw data files. (datafiles - list.files(path=../raw data/, pattern=pp.+\.dat$)) tst - do.call('rbind', lapply(datafiles, function(x) read.table( paste('../raw data/', x, sep=), skip=1))) rm(datafiles) -- Paul Lemmens NICI, University of Nijmegen ASCII Ribbon Campaign /\ Montessorilaan 3 (B.01.05)Against HTML Mail \ / NL-6525 HR Nijmegen X The Netherlands / \ Phonenumber+31-24-3612648 Fax+31-24-3616066 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can't load rgl library
antonio rodriguez schrieb: Hi Thomas, Yes I have the xlibmesa-gl, libglu1-mesa, libglu1-mesa-dev, etc, libraries. But no way. You mentioned TLS (transport Layer Security?), is this OK? I'm working on a Toshiba laptop with graphics driver I852GM No, just look at /usr/share/ to find a diretory named /tls. It seems that if you are running NVidia chip with accelerated driver that wrong driver is loaded (IIRC, it was libnvidia.so1 or something similar). Just rename the mentioned directory to tls_old (don't delete!) and try again to load your package. Just an idea! Thomas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] gnls or nlme : how to obtain confidence intervals of fitted values
Hi I use gnls to fit non linear models of the form y = alpha * x**beta (alpha and beta being linear functions of a 2nd regressor z i.e. alpha=a1+a2*z and beta=b1+b2*z) with variance function varPower(fitted(.)) which sounds correct for the data set I use. My purpose is to use the fitted models for predictions with other sets of regressors x, z than those used in fitting. I therefore need to estimate y with (95%) confidence intervals. Does any body knows how to do this with R ? Thanks __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Reading multiple files into R
Roger Bivand wrote: On Fri, 1 Oct 2004, Vikas Rawal wrote: I want to read data from a number of files into R. Reading individual files one by one requires writing enormous amount of code that will look something like the following. maptools:::dbf.read(wb-01vc.dbf)-dist1 maptools:::dbf.read(wb-02vc.dbf)-dist2 maptools:::dbf.read(wb-03vc.dbf)-dist3 maptools:::dbf.read(wb-04vc.dbf)-dist4 maptools:::dbf.read(wb-05vc.dbf)-dist5 maptools:::dbf.read(wb-06vc.dbf)-dist6 maptools:::dbf.read(wb-07vc.dbf)-dist7 maptools:::dbf.read(wb-08vc.dbf)-dist8 maptools:::dbf.read(wb-09vc.dbf)-dist9 * In this case, you could pre-allocate a list and: res - vector(mode=list, length=9) for (i in 1:length(res)) res[[i]] - maptools:::dbf.read(paste(wb-0, i, vc.dbf, sep=)) res - vector(mode=list, length=9) for (i in 1:length(res)) cat(paste(wb-0, i, vc.dbf, sep=), \n) wb-01vc.dbf wb-02vc.dbf wb-03vc.dbf ... gives a check on what file names are being used. For 10 to 99 preserving the 01-09, use paste(wb-, formatC(i, width=2, flag=0), vc.dbf, sep=). If the token is a character (string) that varies, you can roll out a character vector of tokens first and step along it. res - vector(mode=list, length=length(LETTERS)) for (i in 1:length(res)) cat(paste(wb-, LETTERS[i], vc.dbf, sep=), + \n) wb-Avc.dbf wb-Bvc.dbf wb-Cvc.dbf ... Is there a better way of doing this? Vikas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Good call. Here's a somewhat more R-ified version: res - lapply(paste(wb-, formatC(1:99, width=2, flag=0), vc.dbf, sep=), maptools:::dbf.read) Kevin __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Can't load rgl library
Hi Thomas antonio rodriguez schrieb: Hi Thomas, Yes I have the xlibmesa-gl, libglu1-mesa, libglu1-mesa-dev, etc, libraries. But no way. You mentioned TLS (transport Layer Security?), is this OK? I'm working on a Toshiba laptop with graphics driver I852GM No, just look at /usr/share/ to find a diretory named /tls. It seems that if you are running NVidia chip with accelerated driver that wrong driver is loaded (IIRC, it was libnvidia.so1 or something similar). Just rename the mentioned directory to tls_old (don't delete!) and try again to load your package. Just an idea! No I don't have neither a tls directory under /usr/share nor a NVidia chip. The only tls directory is under /lib and it has a lot of libraries I feel won't do their work if I rename it to tls_old Thanks again :-) Antonio --- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Rnewsletter article example
Hi, I am trying to write an article for the Rnewsletter, but keep getting errors. I have googled around for some decent examples that contain figures, maths, etc but with no joy. Would any be so kind as to send me an example article in latex code? Cheers, Sam. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Rnewsletter article example
me too, E, Samuel Kemp wrote: Hi, I am trying to write an article for the Rnewsletter, but keep getting errors. I have googled around for some decent examples that contain figures, maths, etc but with no joy. Would any be so kind as to send me an example article in latex code? Cheers, Sam. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dipl. bio-chem. Witold Eryk Wolski MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin _ tel: 0049-30-83875219 'v' http://www.molgen.mpg.de/~wolski / \ mail: [EMAIL PROTECTED] ---W-W [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Rnewsletter article example
Samuel Kemp wrote: Hi, I am trying to write an article for the Rnewsletter, but keep getting errors. I have googled around for some decent examples that contain figures, maths, etc but with no joy. Would any be so kind as to send me an example article in latex code? Cheers, I'll send one to both of you in a minute. Also, please read the article in R News 1/1 on how to writes articles. Uwe Ligges __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] arima vs arima0
Nathaniel == Nathaniel B Derby [EMAIL PROTECTED] on Wed, 29 Sep 2004 12:19:51 -0700 (PDT) writes: Nathaniel What is the difference between arima and arima0? Mainly: arima0 is the predecessor of arima. AFAIK, it has only be retained for back-compatibility but shouldn't really be used in new rojects. In more details: 1) carefully read their help pages 2) read the source code :-) Martin __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] multiple dimensional diag()
Hi I have two arbitrarily dimensioned arrays, a and b, with length(dim(a))==length(dim(b)). I want to form a sort of corner-to-corner version of abind(), or a multidimensional version of blockdiag(). In the case of matrices, the function is easy to write and if a=matrix(1,3,4) and b=matrix(2,2,2), then adiag(a,b) would return: [,1] [,2] [,3] [,4] [,5] [,6] [1,]111100 [2,]111100 [3,]111100 [4,]000022 [5,]000022 I am trying to generalize this to two higher dimensional arrays. If x - adiag(a,b) then I want all(dim(x)==dim(a)+dim(b)); and if dim(a)=c(a_1, a_2,...a_d) then x[1:a_1,1:a_2,...,1:a_d]=a, and x[(a_1+1):(a_1+b_1),...,(a_d+1):(a_d+b_d)]=b. Other elements of x are zero. The fact that I'm having difficulty expressing this succinctly makes me think I'm missing something basic. If a and b have identical dimensions [ie all(dim(a)==dim(b)) ], the following ghastly kludge (which is one of many) works: adiag - function(a,b) { if(any(dim(a) != dim(b))){stop(a and b must have identical dimensions)} jj - array(0,rep(2,length(dim(a jj[1] - 1 jj[length(jj)] - 1 jj - kronecker(jj,b) f - function(i){1:i} do.call([-,c(list(jj),sapply(dim(a),f,simplify=FALSE),list(a))) } Then adiag(array(1:8,rep(2,3)),array(-1,rep(2,3))) is OK. What is the best way to bind arbitrarily dimensioned arrays together corner-to-corner? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre SO14 3ZH tel +44(0)23-8059-7743 [EMAIL PROTECTED] (edit in obvious way; spam precaution) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Background color Windows device (newbie)
Dear R Gurus Just started on R ! Using xYplot from Hmisc (R 1.9, W2K) I get a grey/blue background that I would like to change to white (ie no background) or may be to another color. Tried to do that with par(bg) but only changed the color of the trellis heading. What's the right command to do that ? Kind regards, JL PS if anyone has nice default settings for win device please let me know. I used win.slide in Splus but apparently this does not work in R. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Background color Windows device (newbie)
What you should realize is that xYplot() uses lattice, and that color theme is the default for lattice. trellis.device() has the `theme' argument that you can use to change it. The help page explains how you can change the default: theme: list of components that change the settings of the device opened, or, a function that when called produces such a list. The function name can be supplied as a quoted string. A possible use of this argument is to change the default settings at session startup, for example by setting 'options(lattice.theme = col.whitebg)'. If 'theme' is a function, it will not be supplied any arguments, however, it is guaranteed that a device will already be open when it is called, so one may use '.Device' inside the function to ascertain what device has been opened. Andy From: Jean-Louis Abitbol Dear R Gurus Just started on R ! Using xYplot from Hmisc (R 1.9, W2K) I get a grey/blue background that I would like to change to white (ie no background) or may be to another color. Tried to do that with par(bg) but only changed the color of the trellis heading. What's the right command to do that ? Kind regards, JL PS if anyone has nice default settings for win device please let me know. I used win.slide in Splus but apparently this does not work in R. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Background color Windows device (newbie)
See the bg argument to trellis.device(). Here is an example: library(Hmisc) library(lattice) trellis.device(width=7, height=5, new = TRUE, col = FALSE, bg = white) dfr - expand.grid(month=1:12, continent=c('Europe','USA'), sex=c('female','male')) set.seed(1) dfr - upData(dfr, y=month/10 + 1*(sex=='female') + 2*(continent=='Europe') + runif(48,-.15,.15), lower=y - runif(48,.05,.15), upper=y + runif(48,.05,.15)) xYplot(Cbind(y,lower,upper) ~ month,subset=sex=='male' continent=='USA', data=dfr) hope this helps, Chuck Cleland Jean-Louis Abitbol wrote: Dear R Gurus Just started on R ! Using xYplot from Hmisc (R 1.9, W2K) I get a grey/blue background that I would like to change to white (ie no background) or may be to another color. Tried to do that with par(bg) but only changed the color of the trellis heading. What's the right command to do that ? Kind regards, JL PS if anyone has nice default settings for win device please let me know. I used win.slide in Splus but apparently this does not work in R. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dev.print and win.print
Just format your plot suitably and select on the Windows driver portrait or landscape orientation. The rotation in the Windows device driver to landscape is exactly what postscript does for horizontal = TRUE (the default). It's just that Unix print commands do not have rotation built in (in general), so postscript() does. I think a lot of this comes about because by default S-PLUS graphics devices are landscape format, whereas R ones are square. On Thu, 30 Sep 2004, Erin Hodgess wrote: Was there an answer to the question about using dev.print and win.print to print as horizontal = FALSE, please? I was working on it and I didn't find the solution. R 1.9.1 Windows Thanks, Erin Hodgess mailto: [EMAIL PROTECTED] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Rpy vs RSPython
Seth == Seth Falcon [EMAIL PROTECTED] on Thu, 30 Sep 2004 09:40:13 -0700 writes: Seth On Thu, Sep 30, 2004 at 09:57:53AM -0400, Rajarshi Guha wrote: Rpy seems easier to get up and running with, but does anybody have any comments regarding which would be a better system to work with in the long run? Seth I've been using rpy for a number of months and have been very pleased Seth with it. On the other hand, I haven't tried RSPython so I can't Seth really compare. The (other) big difference between the two is that RSPython : Python - R (BI-directional) RPy : Python - R (UNI-directional). __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can grid lines color in a plot be specified?
On Fri, 2004-10-01 at 07:44, Luis Rideau Cruz wrote: R-help Is there any way to specify the color of grid lines in a simple plot? par(color.tick.marks=c(grey)) plot(rnorm(10),tck=1) Thank you This is one approach: plot(rnorm(10)) # Now draw both axes axis(1, tck = 1, col = grey, lty = dotted) axis(2, tck = 1, col = grey, lty = dotted) # Replace the grey plot region border lines with black box() In this case, the grid lines are being drawn after the data is plotted, so it is possible that the lines may overwrite your symbols or other important visual information. An alternative would be to create the plot background first, including the grid lines, then add the data with lines() or points() or other functions. For example: x - rnorm(10) plot(x, type = n) axis(1, tck = 1, col = grey, lty = dotted) axis(2, tck = 1, col = grey, lty = dotted) box() points(x, pch = 19) HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expand.model.frame gives object not found
Why are you using expand.model.frame to update a *formula*? That is what update()'s formula method does. It is rather rare to use expand.model.frame() directly. As ever, we recommend reading a good book on R as applied to whatever you are trying to do -- several of them have examples of using update(). On Thu, 30 Sep 2004, David Hugh-Jones wrote: Hello, I am a (relatively) experienced programmer, but new to R. In short, inexperienced with R or languages like R. I have a problem using R 1.9.1. I have fit some data using glm(), from within a function: formula = as.formula(paste(depvarname, ~, rhs), env=globalenv()) return (glm(formula, family=binomial(link=logit))) I have now come back to the formula and want to add some more variables to it. So I do: expand.model.frame(formulaname, ~ new_variable) but I get the response Error in eval(expr, envir, enclos) : Object foreignaid.dummy not found where foreignaid.dummy is my dependent variable. However, foreignaid.dummy is clearly visible in the global environment: ls(pat=foreignaid.dummy, envir=globalenv()) [1] foreignaid.dummy ... So why is my dependent variable lost? I have read the earlier comments on the same topic, but they seem to indicate that a previous bug was fixed. Am I missing the point about scoping? Any help much appreciated. David Hugh-Jones Essex University Govt Dept __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can grid lines color in a plot be specified?
On Fri, 2004-10-01 at 08:15, Marc Schwartz wrote: On Fri, 2004-10-01 at 07:44, Luis Rideau Cruz wrote: R-help Is there any way to specify the color of grid lines in a simple plot? par(color.tick.marks=c(grey)) plot(rnorm(10),tck=1) Thank you Oknow that I have finished my second cup of coffee... For some reason, I keep forgetting about the grid() function: plot(rnorm(10)) grid() The same comment applies here with respect to the grid being drawn after your data, so you might want to do something like: x - rnorm(10) plot(x, type = n) grid() points(x, pch = 19) See ?grid for more information. Marc __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R-2.0: roadmap? release statements? plans?
On Fri, 1 Oct 2004, Khamenia, Valery wrote: I took a look at last 2 months post in R-help maillist Well, R-devel is about developments in R, and R-help is about help for end users. and surfed through the R-project.org . Unfortunately, I can't find some page with roadmap/statements about major changes coming in R-2.0 in comparison to R-1.9 Note, neither exist: it is 2.0.0 vs 1.9.1. Could anyone point me to the right URL? http://developer.r-project.org The NEWS file in the alpha/beta releases that have been made available, and announced on R-devel, have details of the changes, major and minor. Or just wait for the release on Monday October 4th. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] biplot.princomp with loadings only
Not and have a biplot, as defined by the person who named them. Have you bothered to read the references on the help page? Please read them (more carefully if necessary). On Thu, 30 Sep 2004, Christoph Lehmann wrote: is there a way to plot only the loadings in a biplot (with the nice arrows), and to skip the scores? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] displaying sample size in boxplots
Also note that boxplot.n in the gplots library (part of the gregmisc bundle) automatically adds the number of observations. -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Patrick Drechsler Sent: Wednesday, September 29, 2004 1:47 PM To: [EMAIL PROTECTED] Subject: Re: [R] displaying sample size in boxplots Martin Maechler wrote on 29 Sep 2004 17:11:13 MET: Roger == Roger Bivand [EMAIL PROTECTED] on Wed, 29 Sep 2004 15:09:17 +0200 (CEST) writes: [snip] Roger Perhaps use the names= argument (width can help too): ^^ Indeed! And that's why -- in the good ol' times when the box plot was invented and enhanced, the inventors thought about it. For that reason there's the 'varwidth = TRUE/FALSE' argument in boxplot() Note from help(boxplot) however that the inventors thought it wiser to make the width proportional to the SQRT of the sample size rather than the sample.size itself, i.e., 'varwidth = TRUE' and your proposal are not equivalent. boxplot(expend~stature, width=sample.size/length(expend), + names=paste(levels(stature), , N=, sample.size, sep=)) Here are the current proposals [for cut paste]: library(ISwR) data(energy) attach(energy) ## 1 boxplot(expend~stature) sample.size - tapply(expend, stature, length) ss.ch - paste(N=, sample.size, sep=) mtext(ss.ch, at=1:length(unique(stature)), line=2, side=1) ## 2 (Roger) boxplot(expend~stature, width=sample.size/length(expend), names=paste(levels(stature), , N=, sample.size, sep=)) ## 3 (Roger + Martin): boxplot(expend ~ stature, varwidth= TRUE, names=paste(levels(stature), , N=, sample.size, sep=)) Thanks for the explanation and the nice summary Martin! I can see the point you're making about varwidth. I've read that part in the documentation before but I have to admit that up to now I didn't see the purpose of this parameter. Although there are situations were I prefer to see the number in print somewhere on the plot which I can now easily accomplish with `names'. Also thanks to Stephano for the pointer to the r-newsletter article and to Don for showing me how one implements user defined functions! Cheers Patrick -- For animals, the entire universe has been neatly divided into things to (a) mate with, (b) eat, (c) run away from, and (d) rocks. -- (Terry Pratchett, Equal Rites) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] R-2.0: roadmap? release statements? plans?
Just to keep Valery from thinking that that web page can not be easily found: Go to www.r-project.org and click on `Developer Page' under the heading `R Project'. A suggestion (for CRAN masters?): On CRAN there is a link to the NEWS file for the released version. Maybe it's a good idea to provide one for alpha/beta version (when available) as well? The Windows-specific NEWS is provided for the alpha/beta. Cheers, Andy From: Prof Brian Ripley On Fri, 1 Oct 2004, Khamenia, Valery wrote: I took a look at last 2 months post in R-help maillist Well, R-devel is about developments in R, and R-help is about help for end users. and surfed through the R-project.org . Unfortunately, I can't find some page with roadmap/statements about major changes coming in R-2.0 in comparison to R-1.9 Note, neither exist: it is 2.0.0 vs 1.9.1. Could anyone point me to the right URL? http://developer.r-project.org The NEWS file in the alpha/beta releases that have been made available, and announced on R-devel, have details of the changes, major and minor. Or just wait for the release on Monday October 4th. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] controlling colour in Trellis histogram
Hello. I am sorry for posting a (seemingly) simple question, but I have just spent 2 hours trying to find the answer, without success. I want to make a histogram with conditioning on a factor, using Trellis graphics. However, I do not want any colours (only black and white) either in the histograms or in the strip. There must be some simple argument but I cant find it. Here is my code so far: histogram(~GRC.SLA|as.factor(species.type),data=group.means, + strip=function(...) + strip.default(...,style=1,factor.levels=c(Conifers,Trees,Herbs,Mo nocots))) As a default, this produces the bars in a pale blue and the strip in orange-yellow. Thanks. Bill Shipley Subject Matter Editor, Ecology North American Editor, Annals of Botany Département de biologie, Université de Sherbrooke, Sherbrooke (Québec) J1K 2R1 CANADA [EMAIL PROTECTED] http://callisto.si.usherb.ca:8080/bshipley/ http://callisto.si.usherb.ca:8080/bshipley/ [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R-2.0: roadmap? release statements? plans?
Well, you could download the latest beta-release and look in the NEWS file there. -- Bjørn-Helge Mevik __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] controlling colour in Trellis histogram
Does this help? mydata - data.frame(OPTIMISM = c(29,35,26,22,30,37,29,32,25,35,38,33,41,28,40), PARENTS = rep(c(Both Deceased, One Deceased, Both Alive), c(4,5,6))) library(lattice) trellis.device(width=7, height=5, new = FALSE, col = FALSE, bg = white) histogram(~ OPTIMISM | PARENTS, data=mydata) Bill Shipley wrote: Hello. I am sorry for posting a (seemingly) simple question, but I have just spent 2 hours trying to find the answer, without success. I want to make a histogram with conditioning on a factor, using Trellis graphics. However, I do not want any colours (only black and white) either in the histograms or in the strip. There must be some simple argument but I cant find it. Here is my code so far: histogram(~GRC.SLA|as.factor(species.type),data=group.means, + strip=function(...) + strip.default(...,style=1,factor.levels=c(Conifers,Trees,Herbs,Mo nocots))) As a default, this produces the bars in a pale blue and the strip in orange-yellow. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Can grid lines color in a plot be specified?
I usually use something like abline(h=seq(...),col=green) abline(v=seq(...),col=green) This allows you to have irregularly spaced grid lines if you want. (Say for futures expiration dates in my case.) Also, as Marc pointed out, you may want to draw the lines or points after the grid lines. HTH, David L. Reiner Rho Trading 440 S LaSalle Suite 620 Chicago IL 60605 312-362-4963 -Original Message- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Friday, October 01, 2004 8:16 AM To: Luis Rideau Cruz Cc: R-Help Subject: Re: [R] Can grid lines color in a plot be specified? On Fri, 2004-10-01 at 07:44, Luis Rideau Cruz wrote: R-help Is there any way to specify the color of grid lines in a simple plot? par(color.tick.marks=c(grey)) plot(rnorm(10),tck=1) Thank you This is one approach: plot(rnorm(10)) # Now draw both axes axis(1, tck = 1, col = grey, lty = dotted) axis(2, tck = 1, col = grey, lty = dotted) # Replace the grey plot region border lines with black box() In this case, the grid lines are being drawn after the data is plotted, so it is possible that the lines may overwrite your symbols or other important visual information. An alternative would be to create the plot background first, including the grid lines, then add the data with lines() or points() or other functions. For example: x - rnorm(10) plot(x, type = n) axis(1, tck = 1, col = grey, lty = dotted) axis(2, tck = 1, col = grey, lty = dotted) box() points(x, pch = 19) HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] controlling colour in Trellis histogram
On Friday 01 October 2004 09:16, Bill Shipley wrote: Hello. I am sorry for posting a (seemingly) simple question, but I have just spent 2 hours trying to find the answer, without success. I want to make a histogram with conditioning on a factor, using Trellis graphics. However, I do not want any colours (only black and white) either in the histograms or in the strip. There must be some simple trellis.device(color = FALSE) ## assuming you want the default device. ## See ?trellis.device for more options histogram(...) Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] controlling colour in Trellis histogram
Dear bill, Try opening the Trellis graphics device with trellis.device(color=FALSE). I hope this helps, John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bill Shipley Sent: Friday, October 01, 2004 9:17 AM To: R help list Subject: [R] controlling colour in Trellis histogram Hello. I am sorry for posting a (seemingly) simple question, but I have just spent 2 hours trying to find the answer, without success. I want to make a histogram with conditioning on a factor, using Trellis graphics. However, I do not want any colours (only black and white) either in the histograms or in the strip. There must be some simple argument but I cant find it. Here is my code so far: histogram(~GRC.SLA|as.factor(species.type),data=group.means, + strip=function(...) + strip.default(...,style=1,factor.levels=c(Conifers,Trees, Herbs,Mo nocots))) As a default, this produces the bars in a pale blue and the strip in orange-yellow. Thanks. Bill Shipley Subject Matter Editor, Ecology North American Editor, Annals of Botany Département de biologie, Université de Sherbrooke, Sherbrooke (Québec) J1K 2R1 CANADA [EMAIL PROTECTED] http://callisto.si.usherb.ca:8080/bshipley/ http://callisto.si.usherb.ca:8080/bshipley/ [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] controlling colour in Trellis histogram
On Friday 01 October 2004 09:25, Chuck Cleland wrote: Does this help? mydata - data.frame(OPTIMISM = c(29,35,26,22,30,37,29,32,25,35,38,33,41,28,40), PARENTS = rep(c(Both Deceased, One Deceased, Both Alive), c(4,5,6))) library(lattice) trellis.device(width=7, height=5, new = FALSE, col = FALSE, bg = white) The bg=white is redundant if color=FALSE. Incidentally, if color=TRUE, setting bg=white is IMO bad practice (although it seemed like a good idea at the time), since it creates settings with a white background while the other colors are only suitable for a dark background. To make it more difficult for users to achieve this, the 'bg' argument has been dropped from trellis.device in 2.0.0. Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Lattice .ps graphic is rotated in LaTeX slides
I've generated a version of the classic dotplot of the barley data with library(lattice) data(barley) trellis.device(postscript, color=TRUE, file=barley2x3.ps) old.settings - trellis.par.get() trellis.par.set(background, list(col = white)) lset(list(superpose.symbol=list(pch=c(19, 1, 25, 2, 15, 22, 23), cex=rep(1,7),col=c(blue, red, darkgreen, brown, orange, turquoise, orchid) ))) lset(list(fontsize = list(default = 14))) n - length(levels(barley$year)) dotplot(variety ~ yield | site, data = barley, groups = year, layout = c(2, 3), aspect = .5, xlab = Barley Yield (bushels/acre), key = list(points = Rows(trellis.par.get(superpose.symbol), 1:n), text = list(levels(barley$year)), columns = n)) dev.off() lset(theme=old.settings) It looks fine with gv (though I'd like to make the bounding box tighter), but when I embed it in a LaTeX slide (landscape, using seminar package), \begin{slide} \includegraphics[,height=.6\textheight]{fig/barley2x3.ps} \end{slide} the image is rotated 90 deg CCW. I tried to adjust for this with \includegraphics[angle=-90,height=.6\textheight]{fig/barley2x3.ps} but that gives ! Package graphics Error: Division by 0. What am I doing wrong, or how could I do it differently so it would work? thanks -- Michael Friendly Email: [EMAIL PROTECTED] Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Can grid lines color in a plot be specified?
On Fri, 2004-10-01 at 09:31, [EMAIL PROTECTED] wrote: I usually use something like abline(h=seq(...),col=green) abline(v=seq(...),col=green) This allows you to have irregularly spaced grid lines if you want. (Say for futures expiration dates in my case.) Also, as Marc pointed out, you may want to draw the lines or points after the grid lines. snip Also, again with the aid of further caffeine, as noted in the help for grid(), one can use the 'panel.first' argument in plot() to enable the creation of the grid prior to the plotting of the data. For example: plot(rnorm(10), panel.first = grid(), pch = 19) yields the same results and plotting sequence as: x - rnorm(10) plot(x, type = n) grid() points(x, pch = 19) As an example of using this approach with irregularly space grid lines and axis tick marks, as per David's point: plot(rnorm(10), panel.first = abline(v = c(1, 2, 3, 7), col = grey, lty = dotted), pch = 19, xaxt = n) axis(1, at = c(1, 2, 3, 7)) There is also a 'panel.last' argument available which, of course, is executed after all other plotting is done. More information is available from ?plot.default. I have not done an exhaustive review of all plotting functions/methods, but I suspect not all of them support the panel.first and panel.last arguments. HTH, Marc __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R-2.0: roadmap? release statements? plans?
Khamenia, Valery [EMAIL PROTECTED] writes: Hi all, I took a look at last 2 months post in R-help maillist and surfed through the R-project.org . Unfortunately, I can't find some page with roadmap/statements about major changes coming in R-2.0 in comparison to R-1.9 Could anyone point me to the right URL? You actually got one from me the first time you asked! https://svn.r-project.org/R/trunk/NEWS -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problems in installing Rmpi library
dear all, I am trying to install the Rmpi library on a cluster but I obtain the following error, which concerns the dynamic libraries: Rmpi version: 0.4-8 Rmpi is an interface (wrapper) to MPI APIs with interactive R slave functionalities. See `library (help=Rmpi)' for details. Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library /mypath/.R/library/Rmpi/libs/Rmpi.so: /mypath/.R/library/Rmpi/libs/Rmpi.so: undefined symbol: MPI_Finalize Error in library(Rmpi) : .First.lib failed Error in dyn.unload(x) : dynamic/shared library /mypath/.R/library/Rmpi/libs/Rmpi.so was not loaded Is there anybody who can help me in finding a way to trun around the problem. Thank you for the help, Marco -- Marco Chiarandini, Fachgebiet Intellektik, Fachbereich Informatik, Technische Universität Darmstadt, Hochschulstraße 10, D-64289 Darmstadt - Germany, Office: S2/02 Raum E317 Tel: +49 (0)6151 16-6802 Fax: +49 (0)6151 16-5326 email: [EMAIL PROTECTED] web page: http://www.intellektik.informatik.tu-darmstadt.de/~machud __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple dimensional diag()
Here is a function that does what you want (perhaps): *= a.block.diag - function(a,b) { # a.block.daig combines arrays a and b and builds a new array which has # a and b as blocks on its diagonal. pw 10/2004 if(length(dim.a-dim(a))!= length(dim.b-dim(b))){ stop(a and b must have identical number of dimensions)} s-array(0,dim.a+dim.b) s-do.call([-,c(list(s),lapply(dim.a,seq),list(a))) ind-lapply(seq(dim.b),function(i)seq(dim.b[[i]])+dim.a[[i]]) do.call([-,c(list(s),ind,list(b))) } @ Try: *= a=matrix(1,3,4); b=matrix(2,2,2) a.block.diag(a,b) @ output-start Fri Oct 1 17:20:26 2004 [,1] [,2] [,3] [,4] [,5] [,6] [1,]111100 [2,]111100 [3,]111100 [4,]000022 [5,]000022 output-end and an another example: *= xx-array(1:8,c(2,rep(2,2))); yy-array(-1*(1:9),c(2,rep(3,2))) a.block.diag(xx,yy) @ output-start Fri Oct 1 17:21:38 2004 , , 1 [,1] [,2] [,3] [,4] [,5] [1,]13000 [2,]24000 [3,]00000 [4,]00000 , , 2 [,1] [,2] [,3] [,4] [,5] [1,]57000 [2,]68000 [3,]00000 [4,]00000 , , 3 [,1] [,2] [,3] [,4] [,5] [1,]00000 [2,]00000 [3,]00 -1 -3 -5 [4,]00 -2 -4 -6 , , 4 [,1] [,2] [,3] [,4] [,5] [1,]00000 [2,]00000 [3,]00 -7 -9 -2 [4,]00 -8 -1 -3 , , 5 [,1] [,2] [,3] [,4] [,5] [1,]00000 [2,]00000 [3,]00 -4 -6 -8 [4,]00 -5 -7 -9 output-end a.block.diag is not always the best solution. In case of x-array(1:8,rep(2,3)); y-array(-1,rep(2,3)) the function adiag will be a little bit faster. Peter Wolf Robin Hankin wrote: Hi I have two arbitrarily dimensioned arrays, a and b, with length(dim(a))==length(dim(b)). I want to form a sort of corner-to-corner version of abind(), or a multidimensional version of blockdiag(). In the case of matrices, the function is easy to write and if a=matrix(1,3,4) and b=matrix(2,2,2), then adiag(a,b) would return: [,1] [,2] [,3] [,4] [,5] [,6] [1,]111100 [2,]111100 [3,]111100 [4,]000022 [5,]000022 I am trying to generalize this to two higher dimensional arrays. If x - adiag(a,b) then I want all(dim(x)==dim(a)+dim(b)); and if dim(a)=c(a_1, a_2,...a_d) then x[1:a_1,1:a_2,...,1:a_d]=a, and x[(a_1+1):(a_1+b_1),...,(a_d+1):(a_d+b_d)]=b. Other elements of x are zero. The fact that I'm having difficulty expressing this succinctly makes me think I'm missing something basic. If a and b have identical dimensions [ie all(dim(a)==dim(b)) ], the following ghastly kludge (which is one of many) works: adiag - function(a,b) { if(any(dim(a) != dim(b))){stop(a and b must have identical dimensions)} jj - array(0,rep(2,length(dim(a jj[1] - 1 jj[length(jj)] - 1 jj - kronecker(jj,b) f - function(i){1:i} do.call([-,c(list(jj),sapply(dim(a),f,simplify=FALSE),list(a))) } Then adiag(array(1:8,rep(2,3)),array(-1,rep(2,3))) is OK. What is the best way to bind arbitrarily dimensioned arrays together corner-to-corner? __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides
Michael Friendly [EMAIL PROTECTED] writes: ! Package graphics Error: Division by 0. What am I doing wrong, or how could I do it differently so it would work? You might try \usepackage{graphicx} instead. I seem to recall (vaguely) getting better results with that sometimes. -p -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides
On Fri, 2004-10-01 at 10:58, Peter Dalgaard wrote: Michael Friendly [EMAIL PROTECTED] writes: ! Package graphics Error: Division by 0. What am I doing wrong, or how could I do it differently so it would work? You might try \usepackage{graphicx} instead. I seem to recall (vaguely) getting better results with that sometimes. That should be part of the preamble for using 'seminar', if it is setup properly. There is a decent tutorial for using seminar at: http://astronomy.sussex.ac.uk/~eddie/soft/tutorial.html There is also a great reference for including graphics in LaTeX: www.ctan.org/tex-archive/info/epslatex.pdf FWIW, though I have been using seminar for such presentations, I have been recently looking at the Beamer package: http://latex-beamer.sourceforge.net/ and of course, there is also the Prosper package: http://prosper.sourceforge.net/ The one advantage of the Beamer package, for those that require it, is that it supports pdflatex, which the others do not. Though, it can be used with dvips/latex + ps2pdf, where needed. HTH, Marc __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides
Hi Michael, Michael Friendly wrote on 01 Oct 2004 16:09:45 MET: I've generated a version of the classic dotplot of the barley data with [sniped R-code] It looks fine with gv The image is in landscape format when viewed with gv. \begin{slide} \includegraphics[,height=.6\textheight]{fig/barley2x3.ps} ^^^typo or copypaste error? \end{slide} the image is rotated 90 deg CCW. I tried to adjust for this with \includegraphics[angle=-90,height=.6\textheight]{fig/barley2x3.ps} Short answer: use `width' instead of `height': \includegraphics[angle=-90,width=.8\linewidth]{fig/barley2x3} Long answer: ,[ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=divzero ] | Graphics division by zero | | While the error | | ! Package graphics Error: Division by 0. | | can actually be caused by offering the package a figure which | claims to have a zero dimension, it's more commonly caused by | rotation. | | Objects in TeX may have both height (the height above the | baseline) and depth (the distance the object goes below the | baseline). If you rotate an object by 180 degrees, you convert | its height into depth, and vice versa; if the object started | with zero depth, you've converted it to a zero-height object. | | Suppose you're including your graphic with a command like: | | \includegraphics[angle=180,height=5cm]{myfig.eps} | | In the case that myfig.eps has no depth to start with, the | scaling calculations will produce the division-by-zero error. | | Fortunately, the graphicx package has a keyword totalheight, | which allows you to specify the size of the image relative to | the sum of the object's height and depth, so | | \includegraphics[angle=180,totalheight=5cm]{myfig.eps} | | will resolve the error, and will behave as you might hope. | | If you're using the simpler graphics package, use the * form of | the \resizebox command to specify the use of totalheight: | | \resizebox*{!}{5cm}{% | \rotatebox{180}{% | \includegraphics{myfig.eps}% | }% | } | ` HTH Patrick -- Computer games don't affect kids. If Pacman would have affected us as children, we would now run around in darkened rooms, munching pills and listening to repetetive music. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hier.part
T. Murlidharan Nair wrote: I am using the hier.part package for calculating the goodness of fit. Before I started with my data I tried to use the example that the package comes with . I have loaded the library hier.part and gtools. But the package gives the following error Loading required package: gregmisc Loading required package: gregmisc Warning messages: 1: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, 2: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, I searched for gregmisc package but it unzipped to gtools. Is there something other package with this name or has it been merged with another one ? What about installing the most recent version of gregmisc? install.packages(gregmisc) Uwe Ligges Thanks../ Murli __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Plotting panels at arbitrary places on a map, rather than on a lattice
I think it is easiest to describe what I want in terms of the concrete problem I have. I have data from a number of countries in each of which a sample of people was interviewed. In presenting the results in a forthcoming collaborative publication much emphasis will be placed on the multi-centre nature of the study. Although I suspect colleagues may do this with shaded maps I would prefer to avoid them as (a) they present one fact per country per map (b) they are unfair to the Netherlands and other high density countries. What I would like to do is to make the background represent Europe (ideally with a map but that is a frill) then place simple scattergrams (or radar plots) on it located roughly where the country is. Another way of describing it might be to say that I want something like the panels produced by lattice but at arbitrary coordinates rather than on a rectangular grid. I suspect I have to do this from scratch and I would welcome hints. Am I right that there is no off the shelf way to do this? Is grid the way to go? Looking at the article in Rnews 2(2) and a brief scan of the documentation suggests so. If grid is the way to go then bearing in mind I have never used grid before (a) any hints about the overall possible solution structure would be welcome (b) is this realistic to do within a week or shall I revert to lattice and lose the geography? Is there a simple way to draw a map in the background? It needs to cover as far as Sweden, Spain and Greece. It can be crude, as long as Italy looks roughly like a boot that is fine. I am an epidemiologist not a geographer. Michael Dewey [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Plotting panels at arbitrary places on a map, rather than on a lattice
On Friday 01 October 2004 11:58, Michael Dewey wrote: I think it is easiest to describe what I want in terms of the concrete problem I have. I have data from a number of countries in each of which a sample of people was interviewed. In presenting the results in a forthcoming collaborative publication much emphasis will be placed on the multi-centre nature of the study. Although I suspect colleagues may do this with shaded maps I would prefer to avoid them as (a) they present one fact per country per map (b) they are unfair to the Netherlands and other high density countries. What I would like to do is to make the background represent Europe (ideally with a map but that is a frill) then place simple scattergrams (or radar plots) on it located roughly where the country is. Another way of describing it might be to say that I want something like the panels produced by lattice but at arbitrary coordinates rather than on a rectangular grid. I suspect I have to do this from scratch and I would welcome hints. Am I right that there is no off the shelf way to do this? I'm not terribly familiar with radar plots (and not at all with scattergrams - what are they?), but if you want radar plots as produced by 'stars', then it seems to have an argument called 'location' which you can use to specify the locations of the stars. That sounds like what you might want. You can also specify 'add = TRUE', which, if you call 'stars' after you have already drawn the map, should superpose your radar plots on the map. I'm not sure how best to draw the map you want, but I'm sure there's a way (maybe using the maps package). Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides - PDF weirdness
Barry Rowlingson [EMAIL PROTECTED] writes: Marc Schwartz wrote: The one advantage of the Beamer package, for those that require it, is that it supports pdflatex, which the others do not. Though, it can be used with dvips/latex + ps2pdf, where needed. Has anyone else hit the problem that sometimes occurs with embedded PostScript graphics generated by R when viewed in full-screen mode using Adobe Acrobat Reader in Linux? Yes, its _that_ specific. You get black areas all round your graphic. It looks a mess. Does it in acroread4 and 5. But only Linux, and only full-screen mode. Doesn't seem to want to happen to me, with acrobat 5, in full-screen mode, on Linux, so it must be more specific than that... -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Plotting panels at arbitrary places on a map, rather than on a lattice
On Fri, 1 Oct 2004, Michael Dewey wrote: I think it is easiest to describe what I want in terms of the concrete problem I have. I have data from a number of countries in each of which a sample of people was interviewed. In presenting the results in a forthcoming collaborative publication much emphasis will be placed on the multi-centre nature of the study. Although I suspect colleagues may do this with shaded maps I would prefer to avoid them as (a) they present one fact per country per map (b) they are unfair to the Netherlands and other high density countries. What I would like to do is to make the background represent Europe (ideally with a map but that is a frill) then place simple scattergrams (or radar plots) on it located roughly where the country is. Another way of describing it might be to say that I want something like the panels produced by lattice but at arbitrary coordinates rather than on a rectangular grid. I suspect I have to do this from scratch and I would welcome hints. Am I right that there is no off the shelf way to do this? Is grid the way to go? Looking at the article in Rnews 2(2) and a brief scan of the documentation suggests so. If grid is the way to go then bearing in mind I have never used grid before (a) any hints about the overall possible solution structure would be welcome (b) is this realistic to do within a week or shall I revert to lattice and lose the geography? Perhaps rather R-News 3/2, October 2003, Integrating grid Graphics Output with Base Graphics Output by Paul Murrell. You might even consider just scanning a basemap, using the pixmap package to read it and display it as a backdrop, and using locator() to get the positions for the localised graphics. For a vector backdrop alternative, try the maps package, world map, and either set plotting limits or choose countries (or both to avoid the French overseas administrative divisions), then locator or the World Factbook to give you a label point. Is there a simple way to draw a map in the background? It needs to cover as far as Sweden, Spain and Greece. It can be crude, as long as Italy looks roughly like a boot that is fine. I am an epidemiologist not a geographer. Michael Dewey [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hier.part
T. Murlidharan Nair wrote: It still gives me the same error !! OK, what is your version of R, which OS, which library paths have you set, and is gregmisc installed in more than one of the libraries? What does it unzipped to gtools in your former mail mean (in particular: What is gtools?)? Uwe Ligges Murli Uwe Ligges wrote: T. Murlidharan Nair wrote: I am using the hier.part package for calculating the goodness of fit. Before I started with my data I tried to use the example that the package comes with . I have loaded the library hier.part and gtools. But the package gives the following error Loading required package: gregmisc Loading required package: gregmisc Warning messages: 1: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, 2: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, I searched for gregmisc package but it unzipped to gtools. Is there something other package with this name or has it been merged with another one ? What about installing the most recent version of gregmisc? install.packages(gregmisc) Uwe Ligges Thanks../ Murli __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hier.part
The R version I am using is 1.9.1 . My operating system is windows. gregmisc is installed in only one of the libraries. gregmisc when unzipped gets installed as gtools. After I looked at the index .html page I guess gtools is gregmisc so I am not sure why it is not happy. I can only include it by library(gtools) and not library(gregmisc) since is installed as gtools. No library with the name gregmisc gets installed when I install it using install.packages(gregmisc). Am I missing something here ?? Thanks../Murli Uwe Ligges wrote: T. Murlidharan Nair wrote: It still gives me the same error !! OK, what is your version of R, which OS, which library paths have you set, and is gregmisc installed in more than one of the libraries? What does it unzipped to gtools in your former mail mean (in particular: What is gtools?)? Uwe Ligges Murli Uwe Ligges wrote: T. Murlidharan Nair wrote: I am using the hier.part package for calculating the goodness of fit. Before I started with my data I tried to use the example that the package comes with . I have loaded the library hier.part and gtools. But the package gives the following error Loading required package: gregmisc Loading required package: gregmisc Warning messages: 1: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, 2: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, I searched for gregmisc package but it unzipped to gtools. Is there something other package with this name or has it been merged with another one ? What about installing the most recent version of gregmisc? install.packages(gregmisc) Uwe Ligges Thanks../ Murli __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hier.part
On Fri, 1 Oct 2004, Uwe Ligges wrote: T. Murlidharan Nair wrote: It still gives me the same error !! OK, what is your version of R, which OS, which library paths have you set, and is gregmisc installed in more than one of the libraries? What does it unzipped to gtools in your former mail mean (in particular: What is gtools?)? As announced earlier today, gregmisc turned into a bundle including gtools as a component package. I guess the hier.part package depends on the single gregmisc package that existed before it became a bundle. I think the source of earlier gregmisc package should be in: http://cran.r-project.org/src/contrib/Archive so it is that (latest 1.11.2) which is likely to be the right one. For binaries look for that version number. Uwe Ligges Murli Uwe Ligges wrote: T. Murlidharan Nair wrote: I am using the hier.part package for calculating the goodness of fit. Before I started with my data I tried to use the example that the package comes with . I have loaded the library hier.part and gtools. But the package gives the following error Loading required package: gregmisc Loading required package: gregmisc Warning messages: 1: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, 2: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, I searched for gregmisc package but it unzipped to gtools. Is there something other package with this name or has it been merged with another one ? What about installing the most recent version of gregmisc? install.packages(gregmisc) Uwe Ligges Thanks../ Murli __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hier.part
Roger Bivand wrote: On Fri, 1 Oct 2004, Uwe Ligges wrote: T. Murlidharan Nair wrote: It still gives me the same error !! OK, what is your version of R, which OS, which library paths have you set, and is gregmisc installed in more than one of the libraries? What does it unzipped to gtools in your former mail mean (in particular: What is gtools?)? As announced earlier today, gregmisc turned into a bundle including gtools as a component package. I guess the hier.part package depends on the single gregmisc package that existed before it became a bundle. I think the source of earlier gregmisc package should be in: http://cran.r-project.org/src/contrib/Archive so it is that (latest 1.11.2) which is likely to be the right one. For binaries look for that version number. Thank you, Roger. Looks like I should go home for now ... Uwe Uwe Ligges Murli Uwe Ligges wrote: T. Murlidharan Nair wrote: I am using the hier.part package for calculating the goodness of fit. Before I started with my data I tried to use the example that the package comes with . I have loaded the library hier.part and gtools. But the package gives the following error Loading required package: gregmisc Loading required package: gregmisc Warning messages: 1: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, 2: There is no package called 'gregmisc' in: library(package, character.only = TRUE, logical = TRUE, warn.conflicts = warn.conflicts, I searched for gregmisc package but it unzipped to gtools. Is there something other package with this name or has it been merged with another one ? What about installing the most recent version of gregmisc? install.packages(gregmisc) Uwe Ligges Thanks../ Murli __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides - PDF weirdness
On Fri, 2004-10-01 at 12:54, Peter Dalgaard wrote: Barry Rowlingson [EMAIL PROTECTED] writes: Marc Schwartz wrote: The one advantage of the Beamer package, for those that require it, is that it supports pdflatex, which the others do not. Though, it can be used with dvips/latex + ps2pdf, where needed. Has anyone else hit the problem that sometimes occurs with embedded PostScript graphics generated by R when viewed in full-screen mode using Adobe Acrobat Reader in Linux? Yes, its _that_ specific. You get black areas all round your graphic. It looks a mess. Does it in acroread4 and 5. But only Linux, and only full-screen mode. Doesn't seem to want to happen to me, with acrobat 5, in full-screen mode, on Linux, so it must be more specific than that... Can't say that I have ever seen that and I do use acroread 5 under FC2 for full screen slide presentations. Barry, do you have a specific R example that I could try to replicate here? Marc __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] displaying sample size in boxplots
Gregory R. Warnes wrote on 01 Oct 2004 14:52:05 MET: [...] Here are the current proposals [for cut paste]: library(ISwR) data(energy) attach(energy) ## 1 boxplot(expend~stature) sample.size - tapply(expend, stature, length) ss.ch - paste(N=, sample.size, sep=) mtext(ss.ch, at=1:length(unique(stature)), line=2, side=1) ## 2 (Roger) boxplot(expend~stature, width=sample.size/length(expend), names=paste(levels(stature), , N=, sample.size, sep=)) ## 3 (Roger + Martin): boxplot(expend ~ stature, varwidth= TRUE, names=paste(levels(stature), , N=, sample.size, sep=)) [...] Also note that boxplot.n in the gplots library (part of the gregmisc bundle) automatically adds the number of observations. Thanks Greg! Nice to see that you've written some code just for this purpose. I will of course also take a closer look at the other functions that are bundled in `gregmisc'. Since I'm still new to R: can somebody give me a pointer to the docs where to find instructions on a package (not a function)? I can find the man pages to specific functions with ?functionname (something similar to `texdoc packagename' in tetex)? TIA, Patrick -- Look Ma, this man can twist his fingers as if they were made of rubber, isn't that amazing? -- Not really, he's been using Emacs for years...! __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides - PDF weirdness
On 01 Oct 2004 19:54:45 +0200 Peter Dalgaard wrote: Barry Rowlingson [EMAIL PROTECTED] writes: Marc Schwartz wrote: The one advantage of the Beamer package, for those that require it, is that it supports pdflatex, which the others do not. Though, it can be used with dvips/latex + ps2pdf, where needed. Has anyone else hit the problem that sometimes occurs with embedded PostScript graphics generated by R when viewed in full-screen mode using Adobe Acrobat Reader in Linux? Yes, its _that_ specific. You get black areas all round your graphic. It looks a mess. Does it in acroread4 and 5. But only Linux, and only full-screen mode. Doesn't seem to want to happen to me, with acrobat 5, in full-screen mode, on Linux, so it must be more specific than that... We had that problem with severl pdf-documents at useR! 2004. My suspicion was that it depends somehow on the way the eps-graphic takes until it ends up in the pdf-document. I seem to recall that those slides were usually generated via latex - dvips - ps2pdf or maybe also via latex - dvipdf although this tends to produce nicer pdf. But I never digged deeper into this and just forced the presenters to use xpdf ;-) BTW: when producing pdf-slides, especially with graphics produced by R, I usually don't generate any eps at all but go directly from my Rnw-file Sweave - pdflatex which produces very nice pdf output. Z -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides
That does indeed work! I had read the arguments section of ?postscript, but this will teach me to read the details. There could/should be a trellis.device(eps, ...) that supplies the appropriate defaults. For the perversely inclined I was able to use my original .ps file in this contorted way: \rotatebox{180}{\includegraphics[angle=90,height=.6\textheight]{fig/barley2x3.ps}} thanks, -Michael Marc Schwartz wrote: On Fri, 2004-10-01 at 10:09, Michael Friendly wrote: I've generated a version of the classic dotplot of the barley data with library(lattice) data(barley) trellis.device(postscript, color=TRUE, file=barley2x3.ps) old.settings - trellis.par.get() snip ... Michael, Try the following when specifying the trellis.device: trellis.device(postscript, color = TRUE, file = barley2x3.eps, onefile = FALSE, paper = special, horizontal = FALSE, width = 9, height = 6) See if that works without specifying the angle in your LaTeX for seminar: \begin{slide} \begin{center} \includegraphics[height=.6\textheight]{fig/barley2x3.eps} \end{center} \end{slide} Note that when including graphics in LaTeX, you should use EPS files, which (as noted in ?postscript) require certain device settings to create. These include: onefile = FALSE, paper = special, horizontal = FALSE and the device 'width' and 'height' settings. This will also adjust the size of the bounding box. HTH, Marc Schwartz -- Michael Friendly Email: [EMAIL PROTECTED] Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] 3d matrix * 1d matrix question
Apologies for the rather newbie question, but I haven't been able to figure this out. I've got a 3d matrix (though presumably, the answer would be the same as for a 2d matrix) which I want to multiply by the values in a vector like so: matrix m is: , , 1 [,1] [,2] [1,]16 [2,]27 [3,]38 , , 2 [,1] [,2] [1,] 21 26 [2,] 22 27 [3,] 23 28 , , 3 [,1] [,2] [1,] 41 46 [2,] 42 47 [3,] 43 48 vector v is c(2,10). I want to multiply m by v along the columns to get this result: , , 1 [,1] [,2] [1,]2 60 [2,]4 70 [3,]6 80 , , 2 [,1] [,2] [1,] 42 260 [2,] 44 270 [3,] 46 280 , , 3 [,1] [,2] [1,] 82 460 [2,] 84 470 [3,] 86 480 So, I figured I could do this by populating a new matrix the same dimensions as m with the values from v repeated in the right order and multiplying m by the new matrix. It feels like there should be a one-step way to do this, though, especially since my real data is a very large data set and it would be memory-inefficient to create a new giant temporary matrix. Thanks. --- Gene __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] cumsum over a list or an array
Hello list, my question is related to svd of a matrix: b=matrix(rnorm(50),10,5) mysvd=svd(b) I would like to compute each xi where xi = di* ui %*% t(vi). I do it by : xlist=sapply(1:ncol(b), function(x1,y) y$d[x1]*y$u[,x1]%*%t(y$v[,x1]),y=mysvd,simplify=F) # result is a list xarray=array(sapply(1:ncol(b), function(x1,y) y$d[x1]*y$u[,x1]%*%t(y$v[,x1]),y=mysvd),c(nrow(b),ncol(b),ncol(b))) # result is an array Now i would like to compute cumulative sum: y1=x1 # y[,,1] y2=x1+x2 # y[,,2] ... I have try to do it with apply without succes: y=apply(xarray,c(1,2),cumsum) The results are good but not in the format that I want. I could modify the results to modify the format but I am sure that it exists another faster way. Is it possible to do the same on the list ? Thanks in advance Sincerely Stéphane DRAY -- Département des Sciences Biologiques Université de Montréal, C.P. 6128, succursale centre-ville Montréal, Québec H3C 3J7, Canada Tel : (514) 343-6111 poste 1233 Fax : (514) 343-2293 E-mail : [EMAIL PROTECTED] -- Web http://www.steph280.freesurf.fr/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] dataload for linux
Is there a dataload utility for linux. The link in genstat is down but I managed to find the utility at: http://gurukul.ucc.american.edu/econ/gaussres/UTILITYS/DATALOAD.HTM but this is a dos/windows version. Thank you Jean __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice .ps graphic is rotated in LaTeX slides
You might be encountering the infamous auto-rotation feature. In Unix you can turn it off via something like setenv GS_OPTIONS -dAutoRotatePages=/None (or the bash equivalent). -roger Michael Friendly wrote: I've generated a version of the classic dotplot of the barley data with library(lattice) data(barley) trellis.device(postscript, color=TRUE, file=barley2x3.ps) old.settings - trellis.par.get() trellis.par.set(background, list(col = white)) lset(list(superpose.symbol=list(pch=c(19, 1, 25, 2, 15, 22, 23), cex=rep(1,7),col=c(blue, red, darkgreen, brown, orange, turquoise, orchid) ))) lset(list(fontsize = list(default = 14))) n - length(levels(barley$year)) dotplot(variety ~ yield | site, data = barley, groups = year, layout = c(2, 3), aspect = .5, xlab = Barley Yield (bushels/acre), key = list(points = Rows(trellis.par.get(superpose.symbol), 1:n), text = list(levels(barley$year)), columns = n)) dev.off() lset(theme=old.settings) It looks fine with gv (though I'd like to make the bounding box tighter), but when I embed it in a LaTeX slide (landscape, using seminar package), \begin{slide} \includegraphics[,height=.6\textheight]{fig/barley2x3.ps} \end{slide} the image is rotated 90 deg CCW. I tried to adjust for this with \includegraphics[angle=-90,height=.6\textheight]{fig/barley2x3.ps} but that gives ! Package graphics Error: Division by 0. What am I doing wrong, or how could I do it differently so it would work? thanks __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cumsum over a list or an array
Stephane DRAY stephane.dray at umontreal.ca writes: : : Hello list, : : my question is related to svd of a matrix: : : b=matrix(rnorm(50),10,5) : mysvd=svd(b) : : I would like to compute each xi where xi = di* ui %*% t(vi). I do it by : : : xlist=sapply(1:ncol(b), function(x1,y) : y$d[x1]*y$u[,x1]%*%t(y$v[,x1]),y=mysvd,simplify=F) # result is a list : : xarray=array(sapply(1:ncol(b), function(x1,y) : y$d[x1]*y$u[,x1]%*%t(y$v[,x1]),y=mysvd),c(nrow(b),ncol(b),ncol(b))) # : result is an array : : Now i would like to compute cumulative sum: : : y1=x1 # y[,,1] : y2=x1+x2 # y[,,2] : ... : : I have try to do it with apply without succes: : : y=apply(xarray,c(1,2),cumsum) : : The results are good but not in the format that I want. I could modify the : results to modify the format but I am sure that it exists another faster way. : : Is it possible to do the same on the list ? : : Thanks in advance I assume the format you want is a list in which the ith element is the approximation to b formed from the first i singular values and the associated spaces. Its actually pretty straighforward and short to simply use a for loop: z1 - xlist for(i in 2:length(mysvd$d)) z1[[i]] - z1[[i-1]] + xlist[[i]] or one can do it directly from the output of the svd without using xlist or xarray by simply zeroing all but the first i singular values in udv' in the ith iteration within lapply: z2 - with(mysvd, { idx - seq(along = d) lapply(idx, function(i) u %*% diag(d*(idx=i)) %*% t(v)) }) all.equal(z1, z2) # TRUE __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html