[R] Making a picture that is wide and small height
How do I make a picture that is a horizontal strip? I tried plot(x=c(1,2,3,4),y=c(1,1,1,1)) #works but screen image is square. pdf(ratio.pdf,height=1,width=6) plot(x=c(1,2,3,4),y=c(1,1,1,1)) I got the following error message: Error in plot.new() : figure margins too large Is it possible to produce an on-screen picture that is a horizontal strip? (I use Mac Os X 10.4.11, and quartz().) What about pdf? I have spent many hours trawling through the online help information and this forum, without success. Where is this explained? Thanks for any help David -- View this message in context: http://www.nabble.com/Making-a-picture-that-is-wide-and-small-height-tp20808401p20808401.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] alternative way to replicate()
Dear all, I'm looking for an alternative way to replicate the 2, string for an x number of times, and end up with one string containing 2, x times. I can partly achieve this using replicate(). y - rep(2,, times=3) y [1] 2, 2, 2, The output that I am looking for is, however, 2,2,2,. I also tried to append(), with similar (unsatisfactory) results. z - for (i in 1:3) { + z - append(z, y[i])} z [1] 2, 2, 2, Could anyone suggest how 2, can be replicated to 2,2,2,? Thank you, Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in transform?
On Tue, 2 Dec 2008, hadley wickham wrote: The underlying issue is actually not in transform() but in data.frame(): aq - airquality[sample(1:153,6),] data.frame(aq, list(a=1,b=2)) Error in data.frame(aq, list(a = 1, b = 2)) : arguments imply differing number of rows: 6, 1 data.frame(aq, list(a=1)) Ozone Solar.R Wind Temp Month Day a 3 12 149 12.6 74 5 3 1 31 37 279 7.4 76 5 31 1 34 NA 242 16.1 67 6 3 1 65 NA 101 10.9 84 7 4 1 59 NA 98 11.5 80 6 28 1 13324 259 9.7 73 9 10 1 Is this a bug or a feature? As documented: Objects passed to data.frame should have the same number of rows, but atomic vectors, factors and character vectors protected by I will be recycled a whole number of times if necessary. How did you manage to miss that in the help page? Hadley -- http://had.co.nz/ -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
On Tue, 2 Dec 2008, Jarle Brinchmann wrote: Yes I think so if the errors were normally distributed. Unfortunately I'm far from that but the combination of sem its bootstrap is a good way to deal with it in the normal case. I must admit as a non-statistician I'm a not 100% sure what the difference (if there is one) between a linear functional relationship and a linear structural equation model is as they both deal with hidden variables as far as I can see. U and V are not 'variables' (not random variables) in a linear functional relationship (they are in the closely related linear structural relationship). J. On Tue, Dec 2, 2008 at 9:33 PM, Spencer Graves [EMAIL PROTECTED] wrote: Isn't this a special case of structural equation modeling, handled by the 'sem' package? Spencer Jarle Brinchmann wrote: Thanks for the reply! On Tue, Dec 2, 2008 at 6:34 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: I wonder if you are using this term in its correct technical sense. A linear functional relationship is V = a + bU X = U + e Y = V + f e and f are random errors (often but not necessarily independent) with distributions possibly depending on U and V respectively. This is indeed what I mean, poor phrasing of me. What I have is the effectively the PDF for e f for each instance, and I wish to get a b. For Gaussian errors there are certainly various ways to approach it and the maximum-likelihood estimator is fine and is what I normally use when my errors are sort-of-normal. However in this instance my uncertainty estimates are strongly non-Gaussian and even defining the mode of the distribution becomes rather iffy so I really prefer to sample the likelihoods properly. Using the maximum-likelihood estimator naively in this case is not terribly useful and I have no idea what the derived confidence limits means. Ah well, I guess what I have to do at the moment is to use brute force and try to calculate P(a,b|X,Y) properly using a marginalisation over U (I hadn't done that before, I expect that was part of my problem). Hopefully that will give reasonable uncertainty estimates, lots of pain for a figure nobody will look at for much time :) Thanks, Jarle. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] alternative way to replicate()
have a look at ?paste(), e.g., paste(rep(2, 3), collapse = ,) and if you need a comma at the end, then you can again use paste(), paste(paste(rep(2, 3), collapse = ,), ,, sep = ) I hope it helps. Best, Dimitris Liviu Andronic wrote: Dear all, I'm looking for an alternative way to replicate the 2, string for an x number of times, and end up with one string containing 2, x times. I can partly achieve this using replicate(). y - rep(2,, times=3) y [1] 2, 2, 2, The output that I am looking for is, however, 2,2,2,. I also tried to append(), with similar (unsatisfactory) results. z - for (i in 1:3) { + z - append(z, y[i])} z [1] 2, 2, 2, Could anyone suggest how 2, can be replicated to 2,2,2,? Thank you, Liviu -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] date operations
Thanks a lot Envoyé de mon iPhone Le 3 déc. 08 à 00:39, jim holtman [EMAIL PROTECTED] a écrit : If you want to do the addition, 'unclass' the variable: alpha2+4 [1] 2008-12-25 alpha2 + unclass(alpha1) [1] 2009-02-15 On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a picture that is wide and small height
On Tue, 2 Dec 2008, David Epstein wrote: How do I make a picture that is a horizontal strip? I tried plot(x=c(1,2,3,4),y=c(1,1,1,1)) #works but screen image is square. pdf(ratio.pdf,height=1,width=6) plot(x=c(1,2,3,4),y=c(1,1,1,1)) I got the following error message: Error in plot.new() : figure margins too large Is it possible to produce an on-screen picture that is a horizontal strip? (I use Mac Os X 10.4.11, and quartz().) What about pdf? I have spent many hours trawling through the online help information and this forum, without success. Where is this explained? In 'An Introduction to R', chapter 12. You need to use smaller margins, and either omit the axes or use smaller text (reduce 'pointsize') which will do so automatically. E.g. quartz(height=1, width=6, pointsize=5) plot(x=c(1,2,3,4),y=c(1,1,1,1)) works for me, and you might want something like par(mar=rep(2.1,4)) plot(x=c(1,2,3,4),y=c(1,1,1,1), xlab=, ylab=) Thanks for any help David -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] hypergeometric function
Hi, I hope somebody can help me on how to use the hypergeometric function. I did read through the R documentation on hypergeometric but not really sure what it means. I would like to evaluate the hypergeometric function as follows: F((2*alpha+1)/2, (2*alpha+2)/2 , alpha+1/2, betasq/etasq). where alpha - .75; beta1 - 7 ; beta2 - 5.5; etasq - ((beta1+beta2)/(2*beta1*beta2*(1-rho))) ^2 betasq - ((beta1-beta2)^2+4*beta1*beta2*rho)/(4*beta1^2*beta2^2*(1-rho)^2) I’m not sure which function should be used- either phyper or qhyper or dhyper Thank you so much for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in transform?
On Tue, 2 Dec 2008, Peter Dalgaard wrote: Prof Brian Ripley wrote: As the help page says If some of the values are not vectors of the appropriate length, you deserve whatever you get! Yes (did I write that?). It is a bit annoying with things that almost work, though. [snip] I often need to use this for creating new variables in data frame from those already present. Sorely needed!! Just learn to use indexing: transform() is just syntactic sugar that you are not making use of. ...at least when you're not making use of the scoping aspects. And if you calculate at least one vector of full length, then the issue goes away. transform(aq, a=1,b=2) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 6, 1 transform(aq, a=1,b=2,o=Ozone) Ozone Solar.R Wind Temp Month Day a b o 3 12 149 12.6 74 5 3 1 2 12 31 37 279 7.4 76 5 31 1 2 37 34 NA 242 16.1 67 6 3 1 2 NA 65 NA 101 10.9 84 7 4 1 2 NA 59 NA 98 11.5 80 6 28 1 2 NA 13324 259 9.7 73 9 10 1 2 24 The underlying issue is actually not in transform() but in data.frame(): Well, no, it is in the way that you call data.frame(). If you want to add several variables, pass them as separate arguments rather than as a list (just as they were passed to transform.data.frame). That's a simple change and will make transform.data.frame behave more consistently with cbind.data.frame and data.frame. -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simultaneous plots
On Tue, Dec 02, 2008 at 02:28:18PM -0800, David Epstein wrote: Is there a good and concise way of making simultaneous plots that are identical, but directed to different devices? I'm writing an R-script that produces a pdf file. I would really like to check visually whether the pdf file shows what I expect. So I would like the same commands to produce a plot on screen. At the moment I'm using cut-and-paste, which is not ideal because any corrections have to be done twice---very error-prone. I usually keep my pdf viewer (kpdf) open which automatically refrehes once I re-create the plot. On windows this is a problem, as far as i know. You may get what you are after by storing the plot with recordPlot() and then use replayPlot() to send it to additional devices. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Speeding up casting a dataframe from long to wide format
Hi, I am casting a dataframe from long to wide format. The same codes that works for a smaller dataframe would take a long time (more than two hours and still running) for a longer dataframe of 2495227 rows and ten different predictors. How to make it more efficient ? wer - data.frame(Name=c(1:5, 4:5), Type=c(letters[1:5], letters[4:5]), Predictor=c(A, A, A, A, A, B, B)) wer Name Type Predictor 11a A 22b A 33c A 44d A 55e A 64d B 75e B wer.melt - melt(wer, id.var=c(Name, Type)) cast(wer.melt, Name + Type ~ value, length, fill=0) Name Type A B 11a 1 0 22b 1 0 33c 1 0 44d 1 1 55e 1 1 sessionInfo() R version 2.7.0 (2008-04-22) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reshape_0.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] par(mfrow = ) resets par('cex'), not reduces it
Hello group! I use R 2.8.0 . I've just found out that par(mfrow =) *resets* par ('cex'), not reduces it as documented. To reproduce: par(cex = 0.5) par(mfrow = c(2, 2)) print(par('cex')) It outputs 0.83, not 0.415 as expected. Particularly such a behavior makes plot.acf effectively ignore par ('cex') value for multivariate case. I guess there are more situations where the documented behavior would be more appropriate. I think it is bug in par implementation not in documentation. Could anyone comment on this? Andrey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] hypergeometric
Hi, I hope somebody can help me on how to use the hypergeometric function. I did read through the R documentation on hypergeometric but not really sure what it means. I would like to evaluate the hypergeometric function as follows: F((2*alpha+1)/2, (2*alpha+2)/2 , alpha+1/2, betasq/etasq). I'm not sure which function should be used- either phyper or qhyper or dhyper Where alpha - .75; beta1 - 7 ; beta2 - 5.5; etasq - ((beta1+beta2)/(2*beta1*beta2*(1-rho))) ^2 betasq - ((beta1-beta2)^2+4*beta1*beta2*rho)/(4*beta1^2*beta2^2*(1-rho)^2) Thank you so much for your help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simultaneous plots
On Wed, 3 Dec 2008, Philipp Pagel wrote: On Tue, Dec 02, 2008 at 02:28:18PM -0800, David Epstein wrote: Is there a good and concise way of making simultaneous plots that are identical, but directed to different devices? I'm writing an R-script that produces a pdf file. I would really like to check visually whether the pdf file shows what I expect. So I would like the same commands to produce a plot on screen. At the moment I'm using cut-and-paste, which is not ideal because any corrections have to be done twice---very error-prone. How about dev.copy2pdf ? I usually keep my pdf viewer (kpdf) open which automatically refrehes once I re-create the plot. On windows this is a problem, as far as i know. Depends on the viewer: GSView (and others based on ghostscript) do allow the file to be updated whilst open: Acrobat Reader does not. -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in transform?
Prof Brian Ripley wrote: On Tue, 2 Dec 2008, Peter Dalgaard wrote: Prof Brian Ripley wrote: As the help page says If some of the values are not vectors of the appropriate length, you deserve whatever you get! Yes (did I write that?). It is a bit annoying with things that almost work, though. [snip] I often need to use this for creating new variables in data frame from those already present. Sorely needed!! Just learn to use indexing: transform() is just syntactic sugar that you are not making use of. ...at least when you're not making use of the scoping aspects. And if you calculate at least one vector of full length, then the issue goes away. transform(aq, a=1,b=2) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 6, 1 transform(aq, a=1,b=2,o=Ozone) Ozone Solar.R Wind Temp Month Day a b o 3 12 149 12.6 74 5 3 1 2 12 31 37 279 7.4 76 5 31 1 2 37 34 NA 242 16.1 67 6 3 1 2 NA 65 NA 101 10.9 84 7 4 1 2 NA 59 NA 98 11.5 80 6 28 1 2 NA 13324 259 9.7 73 9 10 1 2 24 The underlying issue is actually not in transform() but in data.frame(): Well, no, it is in the way that you call data.frame(). If you want to add several variables, pass them as separate arguments rather than as a list (just as they were passed to transform.data.frame). That's a simple change and will make transform.data.frame behave more consistently with cbind.data.frame and data.frame. Hmm, you could well be right there. Not quite a simple spot change, though. As far as I see, either it needs do.call, or maybe there is a much more radical simplification possible. I'll have a look. BTW, we have a deparser bug: transform function (_data, ...) UseMethod(transform) environment: namespace:base function (_data, ...) Error: unexpected string constant in function (_data f - function (`_data`, ...) {} attr(f,source)-NULL f function (_data, ...) { } It should deparse with backticks, not the old-style quotes (did that ever work?). -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in transform?
Peter Dalgaard wrote: BTW, we have a deparser bug: transform function (_data, ...) UseMethod(transform) environment: namespace:base function (_data, ...) Error: unexpected string constant in function (_data f - function (`_data`, ...) {} attr(f,source)-NULL f function (_data, ...) { } It should deparse with backticks, not the old-style quotes (did that ever work?). isn't it the same issue as in this simple case: `FALSE` = 0 ls() # FALSE, not `FALSE` vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Speeding up casting a dataframe from long to wide format
Try timing this to see if its any faster: lev - levels(wer$Predictor) out - outer(wer$Predictor, lev, ==) colnames(out) - lev aggregate(out, wer[1:2], sum) Name Type A B 11a 1 0 22b 1 0 33c 1 0 44d 1 1 55e 1 1 On Tue, Dec 2, 2008 at 11:52 PM, Daren Tan [EMAIL PROTECTED] wrote: Hi, I am casting a dataframe from long to wide format. The same codes that works for a smaller dataframe would take a long time (more than two hours and still running) for a longer dataframe of 2495227 rows and ten different predictors. How to make it more efficient ? wer - data.frame(Name=c(1:5, 4:5), Type=c(letters[1:5], letters[4:5]), Predictor=c(A, A, A, A, A, B, B)) wer Name Type Predictor 11a A 22b A 33c A 44d A 55e A 64d B 75e B wer.melt - melt(wer, id.var=c(Name, Type)) cast(wer.melt, Name + Type ~ value, length, fill=0) Name Type A B 11a 1 0 22b 1 0 33c 1 0 44d 1 1 55e 1 1 sessionInfo() R version 2.7.0 (2008-04-22) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reshape_0.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Switch language
Hi there, I've installed R somewhen in German but I'd like to have it in English. The installation of a new version does not change the language setting though I think I've chosen English in the installation process (this choice was available, right?). Can anybody give me a hint? (Error-Messages in German are not easy to get a solution for...) Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2 - suggestion for facet_wrap/grid
Hello R users (and Hadley), facet_wrap and facet_grid function are both very usefull. But they are perhaps a bit redundant. I probably don't see the advantage of two separate functions, but what do you think of this suggestion : add 'nrow' and 'ncol arguments to facet_grid. These arguments would have an effect only if user draws a 1d ribbon of panels (~ var1+ ...). Thank you very much for this wonderfull package. Best regards. david [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Buchinsky estimator
Is there a R package available that facilitates estimation of Buchinsky's two step procedure in order to correct for sample selection in a quantile regression setting? Thanks in advance for any help. Reference: Moshe Bushinsky (2001) Quantile regression with sample selection: estimating women's return to education in the US, Empirical Economics, 26, 87-113 . Geraint Johnes Professor of Economics Lancaster University Management School Lancaster LA1 4YX United Kingdom Tel: +44 1524 594215 Mob: +44 7753 826342 Fax: +44 1524 594244 Skype: geraintjohnes WWW: http://www.lancs.ac.uk/people/ecagj/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Switch language
Hei, in the FAQ on R for Windows it says: 3.4 I selected English for installation but R runs in Chinese. Precisely, you selected English for installation! The language of the installer has nothing to do with the language used to run R: this is completely standard Windows practice (and necessary as different users of the computer may use different languages). The language R uses for menus and messages is determined by the locale: please read the appropriate manual (the R Installation and Administration Manual) for the details. You can ensure that R uses English messages by appending LANGUAGE=en to the shortcut you use to start R, or setting it in the Rconsole file. That should apply to your problem, too... Annette Antje schrieb: Hi there, I've installed R somewhen in German but I'd like to have it in English. The installation of a new version does not change the language setting though I think I've chosen English in the installation process (this choice was available, right?). Can anybody give me a hint? (Error-Messages in German are not easy to get a solution for...) Antje -- Annette Heisswolf Section of Ecology Department of Biology University of Turku 20014 Turku, Finland phone + 358 2 333 6006 fax + 358 2 333 6550 mail[EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Switch language
Perhaps you are on Windows: the answer is in the rw-FAQ http://cran.r-project.org/bin/windows/base/rw-FAQ.html#I-selected-English-for-installation-but-R-runs-in-Chinese If you have another platform either set LANGUAGE=en or (for MacOS X) ask on the appropriate list. On Wed, 3 Dec 2008, Antje wrote: Hi there, I've installed R somewhen in German but I'd like to have it in English. The installation of a new version does not change the language setting though I think I've chosen English in the installation process (this choice was available, right?). Can anybody give me a hint? (Error-Messages in German are not easy to get a solution for...) Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. PLEASE do as we ask! Knowing the platform would save a lot of guesswork as here. -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Switch language
Hello Annette, that explains everything... Thank you! I just thought having an English version of Windows would be enough but indeed my Regional and Language-Setting are set to German... Ciao, Antje Annette Heisswolf schrieb: Hei, in the FAQ on R for Windows it says: 3.4 I selected English for installation but R runs in Chinese. Precisely, you selected English for installation! The language of the installer has nothing to do with the language used to run R: this is completely standard Windows practice (and necessary as different users of the computer may use different languages). The language R uses for menus and messages is determined by the locale: please read the appropriate manual (the R Installation and Administration Manual) for the details. You can ensure that R uses English messages by appending LANGUAGE=en to the shortcut you use to start R, or setting it in the Rconsole file. That should apply to your problem, too... Annette Antje schrieb: Hi there, I've installed R somewhen in German but I'd like to have it in English. The installation of a new version does not change the language setting though I think I've chosen English in the installation process (this choice was available, right?). Can anybody give me a hint? (Error-Messages in German are not easy to get a solution for...) Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in transform?
Wacek Kusnierczyk wrote: It should deparse with backticks, not the old-style quotes (did that ever work?). isn't it the same issue as in this simple case: `FALSE` = 0 ls() # FALSE, not `FALSE` vQ No. ls() always returns a character vector. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sampling from data.frame
sorry for being a little bit imprecise, Chuck interpreted my question as desired. Armin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simultaneous plots
Prof Brian Ripley wrote: How about dev.copy2pdf ? I put the following into a script: quartz(...) #many graphics commands dev.copy2pdf(pdf,file=ratio1.pdf) and then sourced the script. I got the error message Error in pdfFonts(family) : invalid arguments in 'pdfFonts' (must be font names) I found the various help files on dev.copy and dev.next, etc very hard to understand. And I have no idea how to fix the error. I'm trying to use defaults as much as I can. Could you possibly give a few more lines of code by way of example, Brian? And is a dev.off() command needed after the dev.copy()? Thanks a lot for your helpful replies to so many queries. They are much appreciated. David -- View this message in context: http://www.nabble.com/simultaneous-plots-tp20802447p20810628.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with tcl/tk and Rcmdr - urgent help required
Dear John, i did follow the Rcmdr instructions for macosx, having no results though. I am soon upgrading to 10.5 and hope i'll encounter no problems. The silly thing however was that i had installed every file needed for rcmdr to run but apparently had no results. Is there maybe some key point which is usually forgotten, more than what i have done (descripted below)? Ben p.s. i am also attaching Chiara to this email who is providing assistance to the research and is struggling with Rcmdr on her laptop. Il giorno 02/dic/08, alle ore 16:05, John Fox ha scritto: Dear Ben, It seems clear that the problem is in loading the tcltk package. To confirm that, does library(tcltk) fail? I'm not very knowledgeable about Mac OS X. I do have a MacBook, with OS X 10.5, however, and encountered no problems installing and running the Rcmdr package. Have you seen the R Commander installation instructions for Mac OS X 10.4, at http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation- notes.html? If not, maybe something there will help. I'm copying this response to Rob Goedman [EMAIL PROTECTED], who has provided help before. Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of beniamino Sent: December-02-08 7:25 AM To: r-help@r-project.org Subject: [R] Problem with tcl/tk and Rcmdr - urgent help required Hello everyone, i have been searching the whole day, trying ANY solution offered by the internet and before headbanging against the wall would like to try asking for your help. As many others, i am haveing problems loading the Rcmdr package with Macbook running Tiger 10.4.11. X11 version updated to the last one after having manually installed. I have also installed (obviously) the Rcmdr package with all dependencies. However (damn) i keep having the following answer to the library (rcmdr) command: library (Rcmdr) Carico il pacchetto richiesto: tcltk Loading Tcl/Tk interface ... Error in dyn.load(file, DLLpath = DLLpath, ...) : impossibile caricare libreria condivisa '/Library/Frameworks/R.framework/Versions/2.8/Resources/library/ tcltk/libs/i 3 86/tcltk.so': dlopen(/Library/Frameworks/R.framework/Versions/2.8/Resources/ library/tcltk/ l ibs/i386/tcltk.so, 10): Library not loaded: /usr/local/lib/libtcl8.5.dylib Referenced from: /Library/Frameworks/R.framework/Versions/2.8/Resources/library/ tcltk/libs/i3 8 6/tcltk.so Reason: image not found Error : .onLoad non riuscito in 'loadNamespace' per tcltk Errore: pacchetto 'tcltk' non caricato The language is in italian but it basically says it cannot load shared library. x11 is running, the file tcltk.so phisically exists (i have checked myself) and both R and X11 are in their last updated version. I have also tried restarting after updating X11. Can someone try to help me? i have recently swithced to mac and am having an important exam soon. Thanks to anyone. Ben -- View this message in context: http://www.nabble.com/Problem-with-tcl-tk-and- Rcmdr---urgent-help-required-tp20791135p20791135.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hypergeometric
The dhyper etc deal with the hypergeometric _distribution_ while what you appear to want have is the hypergeometric special function (the connection is that the regular hypergeometric function is the generating function for the hypergeometric distribution if I recall correctly). Anyway, what you need, I believe, is the hypergeo library from CRAN. Cheers, Jarle. On Wed, Dec 3, 2008 at 9:17 AM, Zakaria, Roslinazairimah - zakry001 [EMAIL PROTECTED] wrote: Hi, I hope somebody can help me on how to use the hypergeometric function. I did read through the R documentation on hypergeometric but not really sure what it means. I would like to evaluate the hypergeometric function as follows: F((2*alpha+1)/2, (2*alpha+2)/2 , alpha+1/2, betasq/etasq). I'm not sure which function should be used- either phyper or qhyper or dhyper Where alpha - .75; beta1 - 7 ; beta2 - 5.5; etasq - ((beta1+beta2)/(2*beta1*beta2*(1-rho))) ^2 betasq - ((beta1-beta2)^2+4*beta1*beta2*rho)/(4*beta1^2*beta2^2*(1-rho)^2) Thank you so much for your help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in transform?
Many thanks for your kind responses. That's a simple change and will make transform.data.frame behave more consistently with cbind.data.frame and data.frame. Related to above, I find rather inconsistent following behavior: aq - airquality[sample(1:153,6),] data.frame(aq, list(a=1,b=2)) Error in data.frame(aq, list(a = 1, b = 2)) : arguments imply differing number of rows: 6, 1 cbind(aq,list(a1=1,a2=2)) Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 6, 1 but, aq[c(a,b)]-list(1,2) #works fine In my understanding all versions above are conceptually similar and should behave in a same way, and recycling for one row data.frames should be a default. R is an interactive language and behavior like above is a real pain. Just learn to use indexing: transform() is just syntactic sugar that you are not making use of. I really try to use indexing in code all the time I possibly can. But for interactive use with dozens of data transformations and reshapings per day - with just indexing I would probably see stars at the end of the day. Thanks for existence of such syntactic sugars and for packages like Hadley's reshape and plyr. Regards, Vitalie. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] adding a new dataset to the default R distribution
Hi, I am a student in archaeology with some interest in statistics and R. Recently I've obtained the permission to distribute in the public domain a small dataset (named spearheads with 40 obs. of 14 variables) that was used in an introductory statistics book for archaeologists (published in 1994). I've rewritten most of the exercises of that book in R and made them available at http://wiki.iosa.it/diggingnumbers:start along with the original dataset, but I was wondering if there is a standard procedure for getting a new dataset included in the default R distribution, like cars and others. Please add me to CC if replying because I'm not subscribed to the list. Best regards, Stefano -- Stefano Costa http://www.iosa.it/ Open Archaeology __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hypergeometric
The hypergeo package should be able to deal with this, although the function you specify below looks like a degenerate case (if I understand it correctly) so the convergence rate is likely to be slow. Let me know how you get on best wishes Robin (author of hypergeo) Jarle Brinchmann wrote: The dhyper etc deal with the hypergeometric _distribution_ while what you appear to want have is the hypergeometric special function (the connection is that the regular hypergeometric function is the generating function for the hypergeometric distribution if I recall correctly). Anyway, what you need, I believe, is the hypergeo library from CRAN. Cheers, Jarle. On Wed, Dec 3, 2008 at 9:17 AM, Zakaria, Roslinazairimah - zakry001 [EMAIL PROTECTED] wrote: Hi, I hope somebody can help me on how to use the hypergeometric function. I did read through the R documentation on hypergeometric but not really sure what it means. I would like to evaluate the hypergeometric function as follows: F((2*alpha+1)/2, (2*alpha+2)/2 , alpha+1/2, betasq/etasq). I'm not sure which function should be used- either phyper or qhyper or dhyper Where alpha - .75; beta1 - 7 ; beta2 - 5.5; etasq - ((beta1+beta2)/(2*beta1*beta2*(1-rho))) ^2 betasq - ((beta1-beta2)^2+4*beta1*beta2*rho)/(4*beta1^2*beta2^2*(1-rho)^2) Thank you so much for your help. -- Robin K. S. Hankin Uncertainty Analyst University of Cambridge 19 Silver Street Cambridge CB3 9EP 01223-764877 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stuck with repeated values
R Gurus,I have a vector of nearly 90,000 characters from which I have to extract the index of the characters which are repeated. So suppose if x-c(a,a,b,a,b,c,d) then my output would be a vector having the index where the values are repeated i.e (1,2,3,4,5). I have been able to isolate out the values that are repeated from the unique list of characters in x (i.e. y-c(a,b)). One method can be to use a loop on the which function but that would be too time consuming. Any hint on using the apply function effectively would be useful Thanks and Regards Souvik Bandyopadhyay Lecturer, Dept of Biostatistics, Indian Institute of Public Health, Hyderabad [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stuck with repeated values
On 12/3/2008 6:32 AM, SOUVIK BANDYOPADHYAY wrote: R Gurus,I have a vector of nearly 90,000 characters from which I have to extract the index of the characters which are repeated. So suppose if x-c(a,a,b,a,b,c,d) then my output would be a vector having the index where the values are repeated i.e (1,2,3,4,5). I have been able to isolate out the values that are repeated from the unique list of characters in x (i.e. y-c(a,b)). One method can be to use a loop on the which function but that would be too time consuming. Any hint on using the apply function effectively would be useful Thanks and Regards x - c(a,a,b,a,b,c,d) duplicated(x) [1] FALSE TRUE FALSE TRUE TRUE FALSE FALSE x %in% x[duplicated(x)] [1] TRUE TRUE TRUE TRUE TRUE FALSE FALSE which(x %in% x[duplicated(x)]) [1] 1 2 3 4 5 ?duplicated Souvik Bandyopadhyay Lecturer, Dept of Biostatistics, Indian Institute of Public Health, Hyderabad [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simultaneous plots
On Wed, 3 Dec 2008, David Epstein wrote: Prof Brian Ripley wrote: How about dev.copy2pdf ? I put the following into a script: quartz(...) #many graphics commands dev.copy2pdf(pdf,file=ratio1.pdf) Just dev.copy2pdf(file=ratio1.pdf) and then sourced the script. I got the error message Error in pdfFonts(family) : invalid arguments in 'pdfFonts' (must be font names) I found the various help files on dev.copy and dev.next, etc very hard to understand. And I have no idea how to fix the error. I'm trying to use defaults as much as I can. Could you possibly give a few more lines of code by way of example, Brian? And is a dev.off() command needed after the dev.copy()? Thanks a lot for your helpful replies to so many queries. They are much appreciated. David -- View this message in context: http://www.nabble.com/simultaneous-plots-tp20802447p20810628.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding a new dataset to the default R distribution
On Wed, 3 Dec 2008, Stefano Costa wrote: Hi, I am a student in archaeology with some interest in statistics and R. Recently I've obtained the permission to distribute in the public domain a small dataset (named spearheads with 40 obs. of 14 variables) that was used in an introductory statistics book for archaeologists (published in 1994). I've rewritten most of the exercises of that book in R and made them available at http://wiki.iosa.it/diggingnumbers:start along with the original dataset, but I was wondering if there is a standard procedure for getting a new dataset included in the default R distribution, like cars and others. We will only add datasets to R when they are needed for examples in base R (or exceptionally some 'classic' datasets like 'crimtab'). You can always distribute a dataset in a package (and many packages do: there are several packages on CRAN providing support for books including their datasets). Please add me to CC if replying because I'm not subscribed to the list. Best regards, Stefano -- Stefano Costa http://www.iosa.it/ Open Archaeology -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 facet_wrap problem
Hi Stephen, It looks like a bug in facet_wrap which seems to mix up the factor labels (by sorting only the labels but not the plots?). HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: stephen sefick [mailto:[EMAIL PROTECTED] Verzonden: woensdag 3 december 2008 1:09 Aan: ONKELINX, Thierry CC: hadley wickham; R-help Onderwerp: Re: [R] ggplot2 facet_wrap problem If you look at the TSS graph in the faceted example and then look at the plot of just the GPP vs. TSS. They are different graphs all together. The one that is not faceted is correct. On Tue, Dec 2, 2008 at 6:36 PM, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Hi Stephen, I think you will need to clarify what your problem is with the second plot. HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: di 2-12-2008 22:52 Aan: hadley wickham; R-help Onderwerp: [R] ggplot2 facet_wrap problem Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L,
[R] intersection of two matrices
Hi, I have two matrices as follow: matrix A = a=matrix(c(c(abc,abc,bcd,bcd,bce,bce),c(a1,d2,d1,d2,a1,a2)),6,2) and matrix B which contains pair of values : b=matrix(c(c(a1,a2),c(a1,d2)),2,2) In short, I wish to find out pairs of values in matrix a[,2] having same value in a[,1], which occur as a row in matrix b, so that the output becomes : abc bce, or even better abc a1 d2 bce a1 a2 How can I do that? cheers, Joshi _ Ms Tejal Joshi Researcher Center for Biological Sequence Analysis Technical University of Denmark Kemitorvet, Building 208 DK-2800 Kgs. Lyngby, Denmark Phone: +45 4525 6148 [EMAIL PROTECTED] www.cbs.dtu.dk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] intersection of two matrices(updated)
Hi, I have two matrices as follow: matrix A = a=matrix(c(c(abc,abc,bcd,bcd,bce,bce),c(a1,d2,d1,d2,a1,a2)),6,2) and matrix B which contains pair of values : b=matrix(c(c(a1,a1),c(a2,d2)),2,2) In short, I wish to find out pairs of values in matrix a[,2] having same value in a[,1], which occur as a row in matrix b, so that the output becomes : abc bce, or even better abc a1 d2 bce a1 a2 How can I do that? cheers, Joshi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] alternative way to replicate()
Thanks all. All solutions are usable. These two I received off-list: toString(paste(rep(2,3), sep=,)) [1] 2, 2, 2 and paste(rep(2,,3),collapse=) Liviu On Wed, Dec 3, 2008 at 9:14 AM, Dimitris Rizopoulos [EMAIL PROTECTED] wrote: have a look at ?paste(), e.g., paste(rep(2, 3), collapse = ,) and if you need a comma at the end, then you can again use paste(), paste(paste(rep(2, 3), collapse = ,), ,, sep = ) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 - suggestion for facet_wrap/grid
Hi David, facet_wrap and facet_grid function are both very usefull. But they are perhaps a bit redundant. I disagree ;) Conceptually they are rather different: facet_wrap is essentially a 1d layout, while facet_grid is a 2d layout. This has implications for how you specify the faceting, how the facets are labelled, and how the scales can vary. While I could probably force both into a single function, this is rather against the philosophy of ggplot2, which strives towards small objects which only do one thing. This tends to make things a little more verbose, but I think it makes things easier to understand. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 facet_wrap problem
Yes, that's a known bug. It's fixed in the next version which I'm hoping to release early next week. Regards, Hadley On Wed, Dec 3, 2008 at 6:12 AM, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Hi Stephen, It looks like a bug in facet_wrap which seems to mix up the factor labels (by sorting only the labels but not the plots?). HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: stephen sefick [mailto:[EMAIL PROTECTED] Verzonden: woensdag 3 december 2008 1:09 Aan: ONKELINX, Thierry CC: hadley wickham; R-help Onderwerp: Re: [R] ggplot2 facet_wrap problem If you look at the TSS graph in the faceted example and then look at the plot of just the GPP vs. TSS. They are different graphs all together. The one that is not faceted is correct. On Tue, Dec 2, 2008 at 6:36 PM, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Hi Stephen, I think you will need to clarify what your problem is with the second plot. HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: di 2-12-2008 22:52 Aan: hadley wickham; R-help Onderwerp: [R] ggplot2 facet_wrap problem Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L,
Re: [R] intersection of two matrices(updated)
Is this what you want: a [,1] [,2] [1,] abc a1 [2,] abc d2 [3,] bcd d1 [4,] bcd d2 [5,] bce a1 [6,] bce a2 b [,1] [,2] [1,] a1 a2 [2,] a1 d2 x - lapply(split(seq(nrow(a)), a[,1]), function(.indx){ + do.call(rbind, lapply(seq(nrow(b)), function(.row){ + if (any(b[.row, 1] == a[.indx, 2]) any(b[.row, 2] == a[.indx, 2])){ + c(a[.indx[1],1], b[.row,]) + } else NULL + })) + }) do.call(rbind, x) [,1] [,2] [,3] [1,] abc a1 d2 [2,] bce a1 a2 On Wed, Dec 3, 2008 at 7:18 AM, T Joshi [EMAIL PROTECTED] wrote: Hi, I have two matrices as follow: matrix A = a=matrix(c(c(abc,abc,bcd,bcd,bce,bce),c(a1,d2,d1,d2,a1,a2)),6,2) and matrix B which contains pair of values : b=matrix(c(c(a1,a1),c(a2,d2)),2,2) In short, I wish to find out pairs of values in matrix a[,2] having same value in a[,1], which occur as a row in matrix b, so that the output becomes : abc bce, or even better abc a1 d2 bce a1 a2 How can I do that? cheers, Joshi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Speeding up casting a dataframe from long to wide format
Hi Daren, Unfortunately, the current version of reshape isn't very efficient. I'm working on a new version which should be 10-20x times faster for the operation that you're performing, but this won't be ready for a while and in the meantime you might want to try an alternative approach, like the one that Gabor suggested. Hadley On Tue, Dec 2, 2008 at 10:52 PM, Daren Tan [EMAIL PROTECTED] wrote: Hi, I am casting a dataframe from long to wide format. The same codes that works for a smaller dataframe would take a long time (more than two hours and still running) for a longer dataframe of 2495227 rows and ten different predictors. How to make it more efficient ? wer - data.frame(Name=c(1:5, 4:5), Type=c(letters[1:5], letters[4:5]), Predictor=c(A, A, A, A, A, B, B)) wer Name Type Predictor 11a A 22b A 33c A 44d A 55e A 64d B 75e B wer.melt - melt(wer, id.var=c(Name, Type)) cast(wer.melt, Name + Type ~ value, length, fill=0) Name Type A B 11a 1 0 22b 1 0 33c 1 0 44d 1 1 55e 1 1 sessionInfo() R version 2.7.0 (2008-04-22) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reshape_0.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating Tabel for Mean, Deviance
Hi, Can someone help me how to create a table for Min, Max, Mean, Deviance. I have input data like this: Person Age Child 1 517 2 2 517 0 3 517 1 4 5202 5 520 3 6 710 1 7 721 4 8 721 5 9 721 1 Now i want to create a table for the Min, Max, Deviance, and Mean. from the Child Value. It should look like this: Person Age Min Max Mean Deviance 1 517 0 1 0.61 0.62 2 518 1 2 1.61 1.62 3 519 1 4 1.61 2.62 4 520 2 4 2.63 1.42 5 521 1 5 2.61 0.22 6 717 0 1 0.61 0.52 7 718 1 2 1.610.72 8 719 1 4 1.61 0.82 9 720 1 4 2.63 0.12 - what i can do is only manually: data- read.table(test.data) Min(data$Child), Max(data$Child), Mean(data$Child), Deviance(data$Child) I only know how to calculate. But i dont know how to buiild the tabell like this. I would appreciate if someone can help me. Thanks in advance. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Spectral Analysis of Time Series in R
Dear R Community, I am currently student at the Vienna University of Technology writing my Diploma thesis on causality in time series and doing some analyses of time series in R. I have the following questions: (1) Is there a function in R to estimate the PARTIAL spectral coherence of a multivariate time series? If yes, how does this work? Is there an test in R if the partial spectral coherence between two variables is zero? The functions I know (spectrum, etc.) only work to estimate the spectral coherence. (2) For some causality analysis I need an estimate of the inverse of the spectral density matrix of a multivariate time series. Is there any possibility in R to get this? Actually, I would be happy if I could at least get a functional estimate of the spectral density matrix. I guess this should work because R can plot the kernel density estimator of the spectral density, so it should be possible to extract the underlying function estimate. (3) Is there any possibility to do Granger Causality in R? That means fitting an VAR model and testing if some coefficients are zero. Thank you very much in advance! Best Regards, Alexander T __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 facet_wrap problem
yes, I think this is the bug that will be fixed in the next release : http://github.com/hadley/ggplot2/tree/master/NEWS 2008/12/3 ONKELINX, Thierry [EMAIL PROTECTED] Hi Stephen, It looks like a bug in facet_wrap which seems to mix up the factor labels (by sorting only the labels but not the plots?). HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: stephen sefick [mailto:[EMAIL PROTECTED] Verzonden: woensdag 3 december 2008 1:09 Aan: ONKELINX, Thierry CC: hadley wickham; R-help Onderwerp: Re: [R] ggplot2 facet_wrap problem If you look at the TSS graph in the faceted example and then look at the plot of just the GPP vs. TSS. They are different graphs all together. The one that is not faceted is correct. On Tue, Dec 2, 2008 at 6:36 PM, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Hi Stephen, I think you will need to clarify what your problem is with the second plot. HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: di 2-12-2008 22:52 Aan: hadley wickham; R-help Onderwerp: [R] ggplot2 facet_wrap problem Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L,
Re: [R] Spectral Analysis of Time Series in R
Hello Alexander, for (3) see the CRAN-package vars. Best, Bernhard Dear R Community, I am currently student at the Vienna University of Technology writing my Diploma thesis on causality in time series and doing some analyses of time series in R. I have the following questions: (1) Is there a function in R to estimate the PARTIAL spectral coherence of a multivariate time series? If yes, how does this work? Is there an test in R if the partial spectral coherence between two variables is zero? The functions I know (spectrum, etc.) only work to estimate the spectral coherence. (2) For some causality analysis I need an estimate of the inverse of the spectral density matrix of a multivariate time series. Is there any possibility in R to get this? Actually, I would be happy if I could at least get a functional estimate of the spectral density matrix. I guess this should work because R can plot the kernel density estimator of the spectral density, so it should be possible to extract the underlying function estimate. (3) Is there any possibility to do Granger Causality in R? That means fitting an VAR model and testing if some coefficients are zero. Thank you very much in advance! Best Regards, Alexander T __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Function output difficulties
is there anyway for some parts of the function output to not be returned, even if the output has been used to calculate a further part of the function? i have tried invisible() to no avail. Thanks Emma -- View this message in context: http://www.nabble.com/Function-output-difficulties-tp20813117p20813117.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intersection of two matrices
? merge complexkid wrote: Hi, I have two matrices as follow: matrix A = a=matrix(c(c(abc,abc,bcd,bcd,bce,bce),c(a1,d2,d1,d2,a1,a2)),6,2) and matrix B which contains pair of values : b=matrix(c(c(a1,a2),c(a1,d2)),2,2) In short, I wish to find out pairs of values in matrix a[,2] having same value in a[,1], which occur as a row in matrix b, so that the output becomes : abc bce, or even better abc a1 d2 bce a1 a2 How can I do that? cheers, Joshi _ Ms Tejal Joshi Researcher Center for Biological Sequence Analysis Technical University of Denmark Kemitorvet, Building 208 DK-2800 Kgs. Lyngby, Denmark Phone: +45 4525 6148 [EMAIL PROTECTED] www.cbs.dtu.dk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/intersection-of-two-matrices-tp20811826p20814849.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a picture that is wide and small height
Look at the squishplot function in the TeachingDemos package, that may do what you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of David Epstein Sent: Wednesday, December 03, 2008 1:00 AM To: r-help@r-project.org Subject: [R] Making a picture that is wide and small height How do I make a picture that is a horizontal strip? I tried plot(x=c(1,2,3,4),y=c(1,1,1,1)) #works but screen image is square. pdf(ratio.pdf,height=1,width=6) plot(x=c(1,2,3,4),y=c(1,1,1,1)) I got the following error message: Error in plot.new() : figure margins too large Is it possible to produce an on-screen picture that is a horizontal strip? (I use Mac Os X 10.4.11, and quartz().) What about pdf? I have spent many hours trawling through the online help information and this forum, without success. Where is this explained? Thanks for any help David -- View this message in context: http://www.nabble.com/Making-a-picture- that-is-wide-and-small-height-tp20808401p20808401.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] weighted standard deviation
Please assist, how do you find the weighted standard deviation? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fwd: ggplot2 - suggestion for facet_wrap/grid
2008/12/3 hadley wickham [EMAIL PROTECTED] Hi David, facet_wrap and facet_grid function are both very usefull. But they are perhaps a bit redundant. I disagree ;) I was sure :-) Conceptually they are rather different: facet_wrap is essentially a 1d layout, while facet_grid is a 2d layout. This has implications for how you specify the faceting, how the facets are labelled, and how the scales can vary. While I could probably force both into a single function, this is rather against the philosophy of ggplot2, which strives towards small objects which only do one thing. This tends to make things a little more verbose, but I think it makes things easier to understand. OK. I thought that facet_wrap was created to control the layout of facet_grid plot with one-side formula, since a facet_grid plot with one-side formula should be (almost?) identical with a facet_wrap plot with nrow (or ncol) = 1. By the way, I've just test this thing to see the diffences between the two plots : d - ggplot(diamonds, aes(carat, price, fill = ..density..)) + xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1) ## from official documentation d + facet_grid(~ color) d + facet_wrap(~ color) d + facet_wrap(~ color, nrow = 1) Erreur dans rep(list(nullGrob()), nrow * ncol - length(vec)) : argument 'times' incorrect Is this error normal ? facet_wrap must always give a 2d ribbon of panels ? Thank you very much for your patience. david __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] GLMM using lme4
Dear R-experts, I am running R version 2.7.1 on Windows Vista. I have a small dataset which consists of “chick ID”, “year (0, 1)”, “hatching order [HO, defined as first, second and third-hatched chick]”, and the binary outcome of interest “death (0, 1)”. So a subset of my dataset looks like this on a txt file: y ID Yr HO 1 1 1 First 0 2 1 First 0 3 1 Second 0 4 1 First 1 5 1 First 0 6 1 Third 0 7 1 First 0 8 1 Third 0 9 1 First 0 10 1 First 1 11 1 Third 0 12 1 First 0 13 1 First 0 14 1 First 0 15 1 First 0 17 1 First 1 19 1 First 1 20 1 First n ni nj nk I need to run a GLMM using Year (Yr) and chick ID (ID) as random effects in order to account for lack of independence at the nest level (many chicks are siblings) and eliminate “year effect” incase a significant difference exists between years. Using lmer, I specified my model as follows: model1 - lmer(y~HO+(Yr|ID),family=binomial,1) summary(model1) Output: Error en model.frame.default(data = 1, formula = y ~ HO + (Yr + ID), drop.unused.levels = TRUE) : las longitudes de las variables son diferentes (encontrada para 'HO') Q1: What does this error message mean and how can I solve the problema? Q2: Is my model correctly specified? I look forward to hearing from you guys, always so helpful. Lucho __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to solve following equation?
Thanks for this reply, However I am interested to know why I need to modify my function to a=1? Regards, Gabor Grothendieck wrote: Assume a = 1. If not set b = b/a, etc. Now use (1) uniroot f - function(x) b + c/(1+x) + d/(1+x)^2 - 1 - x uniroot(f, 0:1) $root [1] 0.8392679 $f.root [1] 3.049818e-05 $iter [1] 3 $estim.prec [1] 6.103516e-05 or multiply through by 1+x and subtract 1 from both sides giving x = b + c/(1+x) + d/(1+x)^2 - 1 and iterate that. a - b - c - d - 1 x - 0 for(i in 1:25) { + x - b + c/(1+x) + d/(1+x)^2 - 1 + print(x) + } [1] 2 [1] 0.444 [1] 1.171598 [1] 0.6725419 [1] 0.9553676 [1] 0.7729558 [1] 0.8821595 [1] 0.8135892 [1] 0.8554268 [1] 0.829437 [1] 0.8454056 [1] 0.835527 [1] 0.8416126 [1] 0.837854 [1] 0.8401717 [1] 0.838741 [1] 0.8396236 [1] 0.839079 [1] 0.839415 [1] 0.8392076 [1] 0.8393356 [1] 0.8392566 [1] 0.8393053 [1] 0.8392753 [1] 0.8392938 On Mon, Dec 1, 2008 at 9:47 PM, RON70 [EMAIL PROTECTED] wrote: I need to solve a equation like this : a = b/(1+x) + c/(1+x)^2 + d/(1+x)^3 where a,b,c,d are known constant. Is there any R-way to do that? Thanks in advance -- View this message in context: http://www.nabble.com/How-to-solve-following-equation--tp20785063p20785063.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-solve-following-equation--tp20785063p20817656.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] weighted standard deviation
Dear Humphrey, Take a look at ?wtd.mean in Hmisc. HTH, Jorge On Wed, Dec 3, 2008 at 5:43 AM, Humphrey Kaunda [EMAIL PROTECTED] wrote: Please assist, how do you find the weighted standard deviation? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how do I eliminate excess levels in lattice contourplot key / legend?
I'm working on a contourplot( ) graph, the subject of several previous posts to this list. The contours express probabilities from 0 - 1, but the key that is automatically generated by contourplot pads the probability scale with values that are impossible (i.e, range goes from -0.2 to 1.2), which will be confusing to those who view the plot. How can I get the scale to just run from 0 - 1? I have toiled mightily in the depths of the Murrell Sarkar graphics books. Any pointers will be gratefully received. --Seth Minimal, commented code: library(lattice) model - function(a,b,c,d,e, f, X1,X2) # model function for contour plot {J - a + (b*X1) + (c*X2) + (d*X1*X2) + e*(X1^2) + f*(X2^2) pp - exp(J)/(1+exp(J)) return(pp)} g - expand.grid(X1= seq(0.3,0.9,0.01), X2 = seq(0.3,1, 0.01)) ## create x and y data matrix g$z - model(-29, -14, 52, 80, -3, -56, g$X1, g$X2) ## Create variable z using model and g data frame contourplot(z ~ X1 * X2, data = g, region = TRUE, # Add color to background cuts = 5# Number of contour/color intervals. ) Dr. Seth W. Bigelow Sierra Nevada Research Center USFS - PSW. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] GLMM using lme4
Try length(yourvariablename) for all variables in the model. The first error message indicates that the vectors you are using are not of the same length (i.e. they do not contain the same number of observations). The modeling question: Chickens are nested in nest (haha), but you don't have a nest indicator for each chicken in your data. Yr|ID won't pick up the dependence structure for chickens that are from the same nest. 1. Can chickens from different nests differ in mortality? - assume yes - nest random effect 2. Are chickens nested in nests? - clearly yes - nested affect 3. Can circumstances in a year affect mortality? - assume yes (imagine bird flue or whatever you like) - This, to me, suggests a year fixed effect. 4. Are the same nests (or chicken mothers) measured in year 1 and year 2 - assume no Given the assumption above, I would try: y=b0+b1*HO+b2*(yr==1)+nest(i)+HO(ij)+e which would look like: model1 - lmer(y~HO+factor(yr)+(1|nest)+(1|nest:HO),family=binomial,1) But ultimately you will have to answer the modeling question yourself and anyway test the model of whether you controll sufficiently for the dependence structure in your data. I suggest you to pick up Pinheiro and Bates's book and Faraway's Extending the linear model with R. Cheers, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Luciano La Sala Gesendet: Wednesday, December 03, 2008 11:22 AM An: r help Betreff: [R] GLMM using lme4 Dear R-experts, I am running R version 2.7.1 on Windows Vista. I have a small dataset which consists of chick ID, year (0, 1), hatching order [HO, defined as first, second and third-hatched chick], and the binary outcome of interest death (0, 1). So a subset of my dataset looks like this on a txt file: y ID Yr HO 1 1 1 First 0 2 1 First 0 3 1 Second 0 4 1 First 1 5 1 First 0 6 1 Third 0 7 1 First 0 8 1 Third 0 9 1 First 0 10 1 First 1 11 1 Third 0 12 1 First 0 13 1 First 0 14 1 First 0 15 1 First 0 17 1 First 1 19 1 First 1 20 1 First n ni nj nk I need to run a GLMM using Year (Yr) and chick ID (ID) as random effects in order to account for lack of independence at the nest level (many chicks are siblings) and eliminate year effect incase a significant difference exists between years. Using lmer, I specified my model as follows: model1 - lmer(y~HO+(Yr|ID),family=binomial,1) summary(model1) Output: Error en model.frame.default(data = 1, formula = y ~ HO + (Yr + ID), drop.unused.levels = TRUE) : las longitudes de las variables son diferentes (encontrada para 'HO') Q1: What does this error message mean and how can I solve the problema? Q2: Is my model correctly specified? I look forward to hearing from you guys, always so helpful. Lucho __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] date operations
What is odd is that it seems to run ok if we call +.Date directly: +.Date(alpha1, alpha2) [1] 2009-02-15 On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to solve following equation?
You don't. This was just to make the presentation simpler. On Wed, Dec 3, 2008 at 12:32 PM, RON70 [EMAIL PROTECTED] wrote: Thanks for this reply, However I am interested to know why I need to modify my function to a=1? Regards, Gabor Grothendieck wrote: Assume a = 1. If not set b = b/a, etc. Now use (1) uniroot f - function(x) b + c/(1+x) + d/(1+x)^2 - 1 - x uniroot(f, 0:1) $root [1] 0.8392679 $f.root [1] 3.049818e-05 $iter [1] 3 $estim.prec [1] 6.103516e-05 or multiply through by 1+x and subtract 1 from both sides giving x = b + c/(1+x) + d/(1+x)^2 - 1 and iterate that. a - b - c - d - 1 x - 0 for(i in 1:25) { + x - b + c/(1+x) + d/(1+x)^2 - 1 + print(x) + } [1] 2 [1] 0.444 [1] 1.171598 [1] 0.6725419 [1] 0.9553676 [1] 0.7729558 [1] 0.8821595 [1] 0.8135892 [1] 0.8554268 [1] 0.829437 [1] 0.8454056 [1] 0.835527 [1] 0.8416126 [1] 0.837854 [1] 0.8401717 [1] 0.838741 [1] 0.8396236 [1] 0.839079 [1] 0.839415 [1] 0.8392076 [1] 0.8393356 [1] 0.8392566 [1] 0.8393053 [1] 0.8392753 [1] 0.8392938 On Mon, Dec 1, 2008 at 9:47 PM, RON70 [EMAIL PROTECTED] wrote: I need to solve a equation like this : a = b/(1+x) + c/(1+x)^2 + d/(1+x)^3 where a,b,c,d are known constant. Is there any R-way to do that? Thanks in advance -- View this message in context: http://www.nabble.com/How-to-solve-following-equation--tp20785063p20785063.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-solve-following-equation--tp20785063p20817656.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] date operations
On Wed, 2008-12-03 at 13:18 -0500, Gabor Grothendieck wrote: What is odd is that it seems to run ok if we call +.Date directly: +.Date(alpha1, alpha2) [1] 2009-02-15 It also works if you flip the ordering: alpha2 + alpha1 [1] 2009-02-15 Warning message: Incompatible methods (+.Date, Ops.difftime) for + It is just a warning, but one should check that the answer is correct given the perceived problem with different classes of objects. Why it works is not odd if you look at the help for ?`+.Date`, which shows that for this method (correct term?) we need 'date' + 'x', where 'date' is an object of class Date and 'x' is numeric. The OP can avoid the warning by: alpha2 + as.numeric(alpha1) [1] 2009-02-15 If you put alpha1 first (class difftime) that method gets used and alpha2 is coerced to numeric to complete the operation: alpha1+alpha2 Time difference of 14290 days Warning message: Incompatible methods (Ops.difftime, +.Date) for + as.numeric(alpha2) + 56 [1] 14290 To answer the OP's question about conversion, no you don't need to convert Date objects to numerics to work with them. You just need to be aware of method dispatch for `+()` and check that adding objects of differing classes makes sense. Of course, this assumes that the OP wanted the answer as an object of class Date...? G On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function output difficulties
On 03-Dec-08 13:41:53, emj83 wrote: is there anyway for some parts of the function output to not be returned, even if the output has been used to calculate a further part of the function? i have tried invisible() to no avail. Thanks Emma It's not clear what you mean by some parts of the function output. The function output is whatever you nominate it to be, and can include any selection of whatever was computed within the function. For example: testfn - function(x){ X - x^2 ; Y - cos(X) ; Z - (X + Y)/(1 + x) c(X,Z) } testfn(1.1) # [1] 1.21 0.744295 However, I suspect your case may be a bit more complicated than that! If you were to post the function (or something like it), explaining what you want it to return, and in what way it returns what you do not want, it would be easier to help. Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 03-Dec-08 Time: 19:03:29 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] date operations
On Wed, Dec 3, 2008 at 1:57 PM, Gavin Simpson [EMAIL PROTECTED] wrote: On Wed, 2008-12-03 at 13:18 -0500, Gabor Grothendieck wrote: What is odd is that it seems to run ok if we call +.Date directly: +.Date(alpha1, alpha2) [1] 2009-02-15 It also works if you flip the ordering: alpha2 + alpha1 [1] 2009-02-15 Warning message: Incompatible methods (+.Date, Ops.difftime) for + It is just a warning, but one should check that the answer is correct given the perceived problem with different classes of objects. Why it works is not odd if you look at the help for ?`+.Date`, which shows that for this method (correct term?) we need 'date' + 'x', where 'date' is an object of class Date and 'x' is numeric. In fact what it says is that x may be numeric OR difftime. Also the above does not explain it in any case because: +.Date(alpha1, alpha2) [1] 2009-02-15 alpha1+alpha2 Time difference of 14290 days Warning message: Incompatible methods (Ops.difftime, +.Date) for + The OP can avoid the warning by: alpha2 + as.numeric(alpha1) [1] 2009-02-15 His question was how to avoid using as.numeric. If you put alpha1 first (class difftime) that method gets used and alpha2 is coerced to numeric to complete the operation: alpha1+alpha2 Time difference of 14290 days Warning message: Incompatible methods (Ops.difftime, +.Date) for + as.numeric(alpha2) + 56 [1] 14290 To answer the OP's question about conversion, no you don't need to convert Date objects to numerics to work with them. You just need to be aware of method dispatch for `+()` and check that adding objects of differing classes makes sense. Of course, this assumes that the OP wanted the answer as an object of class Date...? G On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing colnames in dataframes
dear all, I'm building new dataframes from bigger one's using e.g. columns F76, F83, F90: JJ-data.frame( c( as.character(rep( gender,3))) , c( F76,6- F83, F90) ) Looking into JJ one has: c.as.character.rep.gender..8... c.6...F73..F78..F79..F82..6...F84..F94..F106..F109 1 w 2 2 w 3 3 m 1 etc. Instead of the automatic colnames 'c.as.character.rep.gender..8' I like to have the colnames 'gender' and 'J.value'. I tried levels, labels etc but without success. OK, I can fix(FF) manually, but this is bad, because it has to be done again and again .. OK, I can do gender.J-c( as.character(rep( gender,3))) Jvalue-c( F76,6- F83, F90) JJ-data.frame(gender.J, J.value) but this is not optimal because 'gender' is depending on rep(.., n) and I have many dataframes KK, LL, .. using 'gender' with different size. Question: is it possible to do something like JJ-data.frame(c( as.character(rep( gender,3))),c( F76,6- F83, F90), ?? col.names=c(gender,Jvalue) ?? ) Sorry, if my question is elementary, but I could not find a fix. Thank your for your advice. hth Wolfgang __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Hmisc latex() and Rcmdr numSummary() percentage issues
Dear R users, I have issues regarding latex() from Hmisc and numSummary() from Rcmdr. Here's an example: library(Rcmdr) data(Angell, package=car) numSummary(Angell[,hetero], statistics=c(mean, sd, quantiles), quantiles=c( 0,.25,.5,.75,1 )) .numSummary - popOutput() latex(as.table(.numSummary$table), cdec=c(2), file=, title=) The resulting LaTeX code (see below) is not compilable, because of the `%' signs present in the column headers, and that are not escaped by latex() (contrary to the behaviour of xtable()). I can solve the issue manually by escaping the percentage signs `\%'. Would there be a way to automatise this? Thank you, Liviu Uncompilable LaTeX % latex.default(as.table(.numSummary$table), cdec = c(2), file = , title = ) % \begin{table}[!tbp] \begin{center} \begin{tabular}{lrrr}\hline\hline \multicolumn{1}{l}{} \multicolumn{1}{c}{mean} \multicolumn{1}{c}{sd} \multicolumn{1}{c}{0%} \multicolumn{1}{c}{25%} \multicolumn{1}{c}{50%} \multicolumn{1}{c}{75%} \multicolumn{1}{c}{100%} \\ \hline $31.37$$20.41$$10.6$$16.9$$23.7$$39$$84.5$\\ \hline \end{tabular} \end{center} \end{table} End of LaTeX Compilable LaTeX % latex.default(as.table(.numSummary$table), cdec = c(2), file = , title = ) % \begin{table}[!tbp] \begin{center} \begin{tabular}{lrrr}\hline\hline \multicolumn{1}{l}{} \multicolumn{1}{c}{mean} \multicolumn{1}{c}{sd} \multicolumn{1}{c}{0\%} \multicolumn{1}{c}{25\%} \multicolumn{1}{c}{50\%} \multicolumn{1}{c}{75\%} \multicolumn{1}{c}{100\%} \\ \hline $31.37$$20.41$$10.6$$16.9$$23.7$$39$$84.5$\\ \hline \end{tabular} \end{center} \end{table} End of LaTeX -- Do you know how to read? http://www.alienetworks.com/srtest.cfm Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] date operations
On Wed, 2008-12-03 at 14:13 -0500, Gabor Grothendieck wrote: snip / Why it works is not odd if you look at the help for ?`+.Date`, which shows that for this method (correct term?) we need 'date' + 'x', where 'date' is an object of class Date and 'x' is numeric. In fact what it says is that x may be numeric OR difftime. Yes, sorry, got distracted with dinner... Also the above does not explain it in any case because: +.Date(alpha1, alpha2) [1] 2009-02-15 I guess something like this is happening: as.Date(as.numeric(alpha1) + as.numeric(alpha2), origin=1970-01-01) [1] 2009-02-15 Although internally, `+.Date` deals with objects of class difftime for either date or x. So technically the help for ?`+.Date` is at odds with the code; although there is a degree of ambiguity in what a 'date object' is? alpha1+alpha2 Time difference of 14290 days Warning message: Incompatible methods (Ops.difftime, +.Date) for + But you are doing method dispatch yourself (by hand) in the first case and allowing `+` to deal with it in the latter. The warning is not coming from `+.Date`(). This looks like an infelicity in non-standard method dispatch that takes place within `+`, a primitive function. It would be nice if `+` didn't raise warnings about potential incompatible classes, but it can't know in advance what methods users might write for it. The OP can avoid the warning by: alpha2 + as.numeric(alpha1) [1] 2009-02-15 His question was how to avoid using as.numeric. Well, I read it as not converting his Dates to numerics (I converted a difftime). But that is splitting hairs ;-) The OP can use `+.Date` directly as you suggest, or ignore the warnings as they are harmless, or coerce the difftime object to numeric as I suggested. It makes no odds in these cases. I guess the main point for the OP is to realise why the warning is there and determine if it is OK to ignore. G If you put alpha1 first (class difftime) that method gets used and alpha2 is coerced to numeric to complete the operation: alpha1+alpha2 Time difference of 14290 days Warning message: Incompatible methods (Ops.difftime, +.Date) for + as.numeric(alpha2) + 56 [1] 14290 To answer the OP's question about conversion, no you don't need to convert Date objects to numerics to work with them. You just need to be aware of method dispatch for `+()` and check that adding objects of differing classes makes sense. Of course, this assumes that the OP wanted the answer as an object of class Date...? G On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] how do I eliminate excess levels in lattice contourplot key / legend?
On Wed, Dec 3, 2008 at 9:13 AM, Seth W Bigelow [EMAIL PROTECTED] wrote: I'm working on a contourplot( ) graph, the subject of several previous posts to this list. The contours express probabilities from 0 - 1, but the key that is automatically generated by contourplot pads the probability scale with values that are impossible (i.e, range goes from -0.2 to 1.2), which will be confusing to those who view the plot. How can I get the scale to just run from 0 - 1? I have toiled mightily in the depths of the Murrell Sarkar graphics books. Any pointers will be gratefully received. --Seth Minimal, commented code: library(lattice) model - function(a,b,c,d,e, f, X1,X2) # model function for contour plot {J - a + (b*X1) + (c*X2) + (d*X1*X2) + e*(X1^2) + f*(X2^2) pp - exp(J)/(1+exp(J)) return(pp)} g - expand.grid(X1= seq(0.3,0.9,0.01), X2 = seq(0.3,1, 0.01)) ## create x and y data matrix g$z - model(-29, -14, 52, 80, -3, -56, g$X1, g$X2) ## Create variable z using model and g data frame contourplot(z ~ X1 * X2, data = g, region = TRUE, # Add color to background cuts = 5# Number of contour/color intervals. ) contourplot(z ~ X1 * X2, data = g, region = TRUE, at = seq(0, 1, length = 6)) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] changing colnames in dataframes
See the help page. You name the arguments, e.g. JJ - data.frame( gender= c( as.character(rep( gender,3))) , J.value -c( F76 ,6-F83, F90) ) The help says Arguments: ...: these arguments are of either the form 'value' or 'tag = value'. Component names are created based on the tag (if present) or the deparsed argument itself. On Wed, 3 Dec 2008, Wolfgang Lindner wrote: dear all, I'm building new dataframes from bigger one's using e.g. columns F76, F83, F90: JJ-data.frame( c( as.character(rep( gender,3))) , c( F76,6- F83, F90) ) Looking into JJ one has: c.as.character.rep.gender..8... c.6...F73..F78..F79..F82..6...F84..F94..F106..F109 1 w 2 2 w 3 3 m 1 etc. Instead of the automatic colnames 'c.as.character.rep.gender..8' I like to have the colnames 'gender' and 'J.value'. I tried levels, labels etc but without success. OK, I can fix(FF) manually, but this is bad, because it has to be done again and again .. OK, I can do gender.J-c( as.character(rep( gender,3))) Jvalue-c( F76,6- F83, F90) JJ-data.frame(gender.J, J.value) but this is not optimal because 'gender' is depending on rep(.., n) and I have many dataframes KK, LL, .. using 'gender' with different size. Question: is it possible to do something like JJ-data.frame(c( as.character(rep( gender,3))),c( F76,6- F83, F90), ?? col.names=c(gender,Jvalue) ?? ) Sorry, if my question is elementary, but I could not find a fix. Thank your for your advice. hth Wolfgang -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strplit code
On Wed, 3 Dec 2008, [EMAIL PROTECTED] wrote: Dear R-users, The strsplit function does not exist in S-plus and I would like to use it. How could I reproduce the function in Splus or access to its source code? With difficulty, as it is almost entirely implemented in C code (in src/main/character.c and src/main/regex.c, as well as the PCRE library).. It is not something I would undertake lightly (and I am the author/maintainer of most of that code). -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strplit code
Dear Brian (and original poster), My apologies -- I didn't notice the original posting. By coincidence, I have a version of strsplit() that I've used to illustrate recursion: Strsplit - function(x, split){ if (length(x) 1) { return(lapply(x, Strsplit, split)) # vectorization } result - character(0) if (nchar(x) == 0) return(result) posn - regexpr(split, x) if (posn = 0) return(x) c(result, substring(x, 1, posn - 1), Recall(substring(x, posn+1, nchar(x)), split)) # recursion } Illustration: strings - c(To be/or not to be/that is the question, + Whether t'is nobler,in the mind, + to suffer the slings:and arrows:of outrageous fortune, + or to take arms;against;a sea of troubles) Strsplit(strings, [/,:;]) [[1]] [1] To beor not to be that is the question [[2]] [1] Whether t'is nobler in the mind [[3]] [1] to suffer the slings and arrowsof outrageous fortune [[4]] [1] or to take arms against a sea of troubles I think that this should work in S-PLUS, though I haven't tried it. Regards, John On Wed, 3 Dec 2008 20:46:56 + (GMT) Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 3 Dec 2008, [EMAIL PROTECTED] wrote: Dear R-users, The strsplit function does not exist in S-plus and I would like to use it. How could I reproduce the function in Splus or access to its source code? With difficulty, as it is almost entirely implemented in C code (in src/main/character.c and src/main/regex.c, as well as the PCRE library).. It is not something I would undertake lightly (and I am the author/maintainer of most of that code). -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] applying a function to another function
Hello, I did a function (sec_conop) whose arguments are syndic, well and wellconop. sec_conop(syndic='01syndic.txt',well='well-1.csv',wellconop='well-1.dat');closeAllConnections() This function takes “well” and “syndic”, matching between them and then it does some transformations. The result is exported to “wellconop”. I will apply this function to one hundred different “wells”. Therefore, for each well I use, the “wellconop argument will change too. For intance if “well” is now well-2.csv, the function will be sec_conop(syndic='01syndic.txt',well='well-2.csv',wellconop='well-2.dat');closeAllConnections() I am trying to apply this function automatically to all “well” I have, but I do not find the way. The last I tried, for three different “wells”, was : wells-data.frame(funct=rep('sec_conop(',3),syndic=c('01syndic.txt','01syndic.txt','01syndic.txt'),well=c('well-1.csv','well-2.csv','well-3-1.csv'),wellconop=c('well-1.dat','well-2.dat','well-3.dat')) funct_3wells-paste(wells$funct,',wells$syndic,', , ,', wells$well,', , , ' ,wells$wellconop,',),;,closeAllConnections(),sep='') lapply(funct_3wells,as.formula) This way works partially because the results in “wellconop” are truncated. Has anyone any suggestion? Thanks in advance Carlos __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reading version 9 SAS datasets in R
Hi, I am trying to read a SAS version 9.1.3 SAS dataset into R (to preserve the SAS labels), but am unable to do so (I have read in a CSV version). I first created a transport file using the SAS code: libname ces2 'D:\CES Analysis\Data'; filename transp 'D:\CES Analysis\Data\fadata.xpt'; /* create a transport file - R cannot read file created by proc cport */ proc cport data=ces2.fadata file=transp; run; I then tried to read it in R using: library(foreign) library(Hmisc) fadata2 - sasxport.get(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format Next I tried using the libname statement and the xport engine to create a transport file. The problem with this method is that variable names cannot be more than 8 characters as this method creates a SAS version 6 transport file. libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; data to_r.fadata2; set ces2.fadata; run; But I get an error message in the SAS log: 493 libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; NOTE: Libref TO_R was successfully assigned as follows: Engine:XPORT Physical Name: D:\CES Analysis\Data\fadata2.xpt 494 495 data to_r.fadata2; 496set ces2.fadata; 497 run; ERROR: The variable name BUS_TEL_N is illegal for the version 6 file TO_R.FADATA2.DATA. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set TO_R.FADATA2 was only partially opened and will not be saved. Next I tried other ways of reading a SAS dataset in R, as shown below: fadata2 - sas.get(D:\\CES Analysis\\Data, mem=fadata) Error in sas.get(D:\\CES Analysis\\Data, mem = fadata) : Unix file, D:\CES Analysis\Data/c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, .sd2 D:\CES Analysis\Data/c(NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, In addition: Warning message: In sas.get(D:\\CES Analysis\\Data, mem = fadata) : D:\CES Analysis\Data/formats.sc? or formats.sas7bcat not found. Formatting ignored. ls() [1] fadata ?read.xport fadata2 - read.xport(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format ?read.ssd fadata2 - read.ssd(D:\\CES Analysis\\Data, fadata) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file72ae2cd6.sas The log file will be file72ae2cd6.log in the current directory Warning messages: 1: In system(paste(sascmd, tmpProg)) : sas not found 2: In read.ssd(D:\\CES Analysis\\Data, fadata) : SAS return code was -1 sashome - C:\\Program Files\\SAS\\SAS 9.1 fadata2 - read.ssd(file.path(sashome, core, sashelp), fadata, sascmd=file.path(sashome, sas.exe)) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file6df11649.sas The log file will be file6df11649.log in the current directory Warning message: In read.ssd(file.path(sashome, core, sashelp), fadata, sascmd = file.path(sashome, : SAS return code was 2 Is there any way I can read in a SAS version 9 dataset in R, so that I can preserve the SAS labels? If I have to change the SAS variable names to be 8 characters or less, to create a SAS version 6 transport file, I could probably do without the SAS labels as I have already read in the data into R from a CSV file. Thanks in advance for any help. Jude ___ Jude Ryan Director, Client Analytic Services Strategy Business Development UBS Financial Services Inc. 1200 Harbor Boulevard, 4th Floor Weehawken, NJ 07086-6791 Tel. 201-352-1935 Fax 201-272-2914 Email: [EMAIL PROTECTED] Please do not transmit orders or instructions regarding a UBS account by e-mail. The information provided in this e-mail or any attachments is not an official transaction confirmation or account statement. For your protection, do not include account numbers, Social Security numbers, credit card numbers, passwords or other non-public information in your e-mail. Because the information contained in this message may be privileged, confidential, proprietary or otherwise
Re: [R] reading version 9 SAS datasets in R
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, December 03, 2008 1:40 PM To: r-help@r-project.org Cc: [EMAIL PROTECTED] Subject: [R] reading version 9 SAS datasets in R Hi, I am trying to read a SAS version 9.1.3 SAS dataset into R (to preserve the SAS labels), but am unable to do so (I have read in a CSV version). I first created a transport file using the SAS code: libname ces2 'D:\CES Analysis\Data'; filename transp 'D:\CES Analysis\Data\fadata.xpt'; /* create a transport file - R cannot read file created by proc cport */ proc cport data=ces2.fadata file=transp; run; I then tried to read it in R using: library(foreign) library(Hmisc) fadata2 - sasxport.get(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format Next I tried using the libname statement and the xport engine to create a transport file. The problem with this method is that variable names cannot be more than 8 characters as this method creates a SAS version 6 transport file. libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; data to_r.fadata2; set ces2.fadata; run; But I get an error message in the SAS log: 493 libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; NOTE: Libref TO_R was successfully assigned as follows: Engine:XPORT Physical Name: D:\CES Analysis\Data\fadata2.xpt 494 495 data to_r.fadata2; 496set ces2.fadata; 497 run; ERROR: The variable name BUS_TEL_N is illegal for the version 6 file TO_R.FADATA2.DATA. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set TO_R.FADATA2 was only partially opened and will not be saved. Next I tried other ways of reading a SAS dataset in R, as shown below: fadata2 - sas.get(D:\\CES Analysis\\Data, mem=fadata) Error in sas.get(D:\\CES Analysis\\Data, mem = fadata) : Unix file, D:\CES Analysis\Data/c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, .sd2 D:\CES Analysis\Data/c(NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, In addition: Warning message: In sas.get(D:\\CES Analysis\\Data, mem = fadata) : D:\CES Analysis\Data/formats.sc? or formats.sas7bcat not found. Formatting ignored. ls() [1] fadata ?read.xport fadata2 - read.xport(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format ?read.ssd fadata2 - read.ssd(D:\\CES Analysis\\Data, fadata) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file72ae2cd6.sas The log file will be file72ae2cd6.log in the current directory Warning messages: 1: In system(paste(sascmd, tmpProg)) : sas not found 2: In read.ssd(D:\\CES Analysis\\Data, fadata) : SAS return code was -1 sashome - C:\\Program Files\\SAS\\SAS 9.1 fadata2 - read.ssd(file.path(sashome, core, sashelp), fadata, sascmd=file.path(sashome, sas.exe)) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file6df11649.sas The log file will be file6df11649.log in the current directory Warning message: In read.ssd(file.path(sashome, core, sashelp), fadata, sascmd = file.path(sashome, : SAS return code was 2 Is there any way I can read in a SAS version 9 dataset in R, so that I can preserve the SAS labels? If I have to change the SAS variable names to be 8 characters or less, to create a SAS version 6 transport file, I could probably do without the SAS labels as I have already read in the data into R from a CSV file. Thanks in advance for any help. Jude ___ Jude Ryan Director, Client Analytic Services Strategy Business Development UBS Financial Services Inc. 1200 Harbor Boulevard, 4th Floor Weehawken, NJ 07086-6791 Tel. 201-352-1935 Fax 201-272-2914 Email: [EMAIL PROTECTED] Jude, Since
Re: [R] reading version 9 SAS datasets in R
[EMAIL PROTECTED] wrote: Hi, I am trying to read a SAS version 9.1.3 SAS dataset into R (to preserve the SAS labels), but am unable to do so (I have read in a CSV version). I first created a transport file using the SAS code: libname ces2 'D:\CES Analysis\Data'; filename transp 'D:\CES Analysis\Data\fadata.xpt'; Try FILENAME transp SASV5XPT 'D:\CES Analysis\Data\fadata.xpt'; Frank /* create a transport file - R cannot read file created by proc cport */ proc cport data=ces2.fadata file=transp; run; I then tried to read it in R using: library(foreign) library(Hmisc) fadata2 - sasxport.get(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format Next I tried using the libname statement and the xport engine to create a transport file. The problem with this method is that variable names cannot be more than 8 characters as this method creates a SAS version 6 transport file. libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; data to_r.fadata2; set ces2.fadata; run; But I get an error message in the SAS log: 493 libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; NOTE: Libref TO_R was successfully assigned as follows: Engine:XPORT Physical Name: D:\CES Analysis\Data\fadata2.xpt 494 495 data to_r.fadata2; 496set ces2.fadata; 497 run; ERROR: The variable name BUS_TEL_N is illegal for the version 6 file TO_R.FADATA2.DATA. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set TO_R.FADATA2 was only partially opened and will not be saved. Next I tried other ways of reading a SAS dataset in R, as shown below: fadata2 - sas.get(D:\\CES Analysis\\Data, mem=fadata) Error in sas.get(D:\\CES Analysis\\Data, mem = fadata) : Unix file, D:\CES Analysis\Data/c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, .sd2 D:\CES Analysis\Data/c(NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, In addition: Warning message: In sas.get(D:\\CES Analysis\\Data, mem = fadata) : D:\CES Analysis\Data/formats.sc? or formats.sas7bcat not found. Formatting ignored. ls() [1] fadata ?read.xport fadata2 - read.xport(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format ?read.ssd fadata2 - read.ssd(D:\\CES Analysis\\Data, fadata) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file72ae2cd6.sas The log file will be file72ae2cd6.log in the current directory Warning messages: 1: In system(paste(sascmd, tmpProg)) : sas not found 2: In read.ssd(D:\\CES Analysis\\Data, fadata) : SAS return code was -1 sashome - C:\\Program Files\\SAS\\SAS 9.1 fadata2 - read.ssd(file.path(sashome, core, sashelp), fadata, sascmd=file.path(sashome, sas.exe)) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file6df11649.sas The log file will be file6df11649.log in the current directory Warning message: In read.ssd(file.path(sashome, core, sashelp), fadata, sascmd = file.path(sashome, : SAS return code was 2 Is there any way I can read in a SAS version 9 dataset in R, so that I can preserve the SAS labels? If I have to change the SAS variable names to be 8 characters or less, to create a SAS version 6 transport file, I could probably do without the SAS labels as I have already read in the data into R from a CSV file. Thanks in advance for any help. Jude ___ Jude Ryan Director, Client Analytic Services Strategy Business Development UBS Financial Services Inc. 1200 Harbor Boulevard, 4th Floor Weehawken, NJ 07086-6791 Tel. 201-352-1935 Fax 201-272-2914 Email: [EMAIL PROTECTED] Please do not transmit orders or instructions regarding a UBS account by e-mail. The information provided in this e-mail or any attachments is not an official transaction confirmation or account statement. For your protection, do not include account numbers, Social Security numbers, credit card numbers, passwords or other non-public information
[R] Random Forest weighting
Folks, I have a query around weighting in Random Forest (RF). I know that several earlier emails in this group have raised this issue, but I did not find an answer to my query. I am working on a dataset (dataset1) that consists of 4 million records that can be reduced to a dataset (dataset2) of approximately 1500 unique records with frequency counts that add up to the 4 million records number as above. Because of size issues, I cannot work with dataset1 in R and therefore, I am working with dataset2 . Each record consists of whether or not a patient chose a particular drug based on 14 comorbidity (Yes / No) variables; I am using RF to understand the comorbidity drivers of drug adoption (yes/no) classification. At full dataset level (dataset1), the drug adoption incidence is ~11%. At the reduced dataset dataset2 level, the drug adoption incidence increases to ~38%. My question is that, if am using the reduced dataset (dataset2), how should I inform RF that the adoption incidence at the full dataset level was 11%. Should that be used as a classwt prior with classwt=c(Yes=.11, No=.89)? My understanding is that RF does not allow case weighting. Or can this be handled with the sampsize arguement through oversampling? What proportions should one use for this (e.g., sampsize=c(Yes=100, No=100))? I would appreciate any feedback or pointers to any earlier thread that I may have overlooked. Regards, Raghu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading version 9 SAS datasets in R
Frank E Harrell Jr wrote: [EMAIL PROTECTED] wrote: Hi, I am trying to read a SAS version 9.1.3 SAS dataset into R (to preserve the SAS labels), but am unable to do so (I have read in a CSV version). I first created a transport file using the SAS code: libname ces2 'D:\CES Analysis\Data'; filename transp 'D:\CES Analysis\Data\fadata.xpt'; Try FILENAME transp SASV5XPT 'D:\CES Analysis\Data\fadata.xpt'; Sorry I screwed that up. See http://biostat.mc.vanderbilt.edu/SASexportHowto for the correct approach, under the heading If You Have Access to SAS. Frank Frank /* create a transport file - R cannot read file created by proc cport */ proc cport data=ces2.fadata file=transp; run; I then tried to read it in R using: library(foreign) library(Hmisc) fadata2 - sasxport.get(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format Next I tried using the libname statement and the xport engine to create a transport file. The problem with this method is that variable names cannot be more than 8 characters as this method creates a SAS version 6 transport file. libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; data to_r.fadata2; set ces2.fadata; run; But I get an error message in the SAS log: 493 libname to_r xport 'D:\CES Analysis\Data\fadata2.xpt'; NOTE: Libref TO_R was successfully assigned as follows: Engine:XPORT Physical Name: D:\CES Analysis\Data\fadata2.xpt 494 495 data to_r.fadata2; 496set ces2.fadata; 497 run; ERROR: The variable name BUS_TEL_N is illegal for the version 6 file TO_R.FADATA2.DATA. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set TO_R.FADATA2 was only partially opened and will not be saved. Next I tried other ways of reading a SAS dataset in R, as shown below: fadata2 - sas.get(D:\\CES Analysis\\Data, mem=fadata) Error in sas.get(D:\\CES Analysis\\Data, mem = fadata) : Unix file, D:\CES Analysis\Data/c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, .sd2 D:\CES Analysis\Data/c(NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 64716, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, In addition: Warning message: In sas.get(D:\\CES Analysis\\Data, mem = fadata) : D:\CES Analysis\Data/formats.sc? or formats.sas7bcat not found. Formatting ignored. ls() [1] fadata ?read.xport fadata2 - read.xport(D:\\CES Analysis\\Data\\fadata.xpt) Error in lookup.xport(file) : file not in SAS transfer format ?read.ssd fadata2 - read.ssd(D:\\CES Analysis\\Data, fadata) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file72ae2cd6.sas The log file will be file72ae2cd6.log in the current directory Warning messages: 1: In system(paste(sascmd, tmpProg)) : sas not found 2: In read.ssd(D:\\CES Analysis\\Data, fadata) : SAS return code was -1 sashome - C:\\Program Files\\SAS\\SAS 9.1 fadata2 - read.ssd(file.path(sashome, core, sashelp), fadata, sascmd=file.path(sashome, sas.exe)) SAS failed. SAS program at D:\DOCUME~1\re06572\LOCALS~1\Temp\RtmpLqCVUx\file6df11649.sas The log file will be file6df11649.log in the current directory Warning message: In read.ssd(file.path(sashome, core, sashelp), fadata, sascmd = file.path(sashome, : SAS return code was 2 Is there any way I can read in a SAS version 9 dataset in R, so that I can preserve the SAS labels? If I have to change the SAS variable names to be 8 characters or less, to create a SAS version 6 transport file, I could probably do without the SAS labels as I have already read in the data into R from a CSV file. Thanks in advance for any help. Jude ___ Jude Ryan Director, Client Analytic Services Strategy Business Development UBS Financial Services Inc. 1200 Harbor Boulevard, 4th Floor Weehawken, NJ 07086-6791 Tel. 201-352-1935 Fax 201-272-2914 Email: [EMAIL PROTECTED] Please do not transmit orders or instructions regarding a UBS account by e-mail. The information provided in this e-mail or any attachments is not an official transaction
[R] Static random numbers
Hello, can anybody help me out saving random numbers? What I am doing is to generate a series of random numbers and keep it as a zoo object. z - 1000 rn1 - as.zoo(rnorm(z)) The random numbers will be analyzed and described in a LaTeX document, so I have to keep them static somehow. The fact that they are kept as a zoo object should not be of too much concern here. Thanks in advance. Regards Bastian Offermann __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Static random numbers
on 12/03/2008 06:10 PM Bastian Offermann wrote: Hello, can anybody help me out saving random numbers? What I am doing is to generate a series of random numbers and keep it as a zoo object. z - 1000 rn1 - as.zoo(rnorm(z)) The random numbers will be analyzed and described in a LaTeX document, so I have to keep them static somehow. The fact that they are kept as a zoo object should not be of too much concern here. Thanks in advance. Regards Bastian Offermann See ?set.seed, which will allow you to specify the seed for the RNG, so that you can reproduce the same sequence again in the future: set.seed(1) rn1 - as.zoo(rnorm(1000)) HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with reading code
I would like to give out the equation for calculating the maximum likelihood. Below is the code, but I still have problems with it. After I read the code, I found there are two cases for w(weights). If w is not zero, then the equation is given as val - 0.5 * (sum(log(w)) - N * (log(2 * pi) + 1 - log(N) + log(sum(w * res^2. However, if w is zero, then I do not know what equation it should be since it does not make any sense for log0. Hope someone can help me to figure this out. Thanks! function (object, REML = FALSE, ...) { res - object$residuals p - object$rank N - length(res) if (is.null(w - object$weights)) { w - rep.int(1, N) } else { excl - w == 0 #I can not understand the following lines after this. if (any(excl)) { res - res[!excl] N - length(res) w - w[!excl]} } N0 - N if (REML) N - N - p val - 0.5 * (sum(log(w)) - N * (log(2 * pi) + 1 - log(N) + log(sum(w * res^2 if (REML) val - val - sum(log(abs(diag(object$qr$qr)[1:p]))) attr(val, nall) - N0 attr(val, nobs) - N attr(val, df) - p + 1 class(val) - logLik val } Best, Dana -- View this message in context: http://www.nabble.com/Help-with-reading-code-tp20823979p20823979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with reading code
Hi Dana -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dana77 Sent: Wednesday, December 03, 2008 3:24 PM To: r-help@r-project.org Subject: [R] Help with reading code I would like to give out the equation for calculating the maximum likelihood. Below is the code, but I still have problems with it. After I read the code, I found there are two cases for w(weights). If w is not zero, then the equation is given as val - 0.5 * (sum(log(w)) - N * (log(2 * pi) + 1 - log(N) + log(sum(w * res^2. However, if w is zero, then I do not know what equation it should be since it does not make any sense for log0. Hope someone can help me to figure this out. Thanks! function (object, REML = FALSE, ...) { res - object$residuals p - object$rank N - length(res) if (is.null(w - object$weights)) { w - rep.int(1, N) } else { excl - w == 0 #I can not understand the following lines after this. The command above sets a variable to exclude with. Any observation with weight equal to zero will get excluded. excl will have value TRUE for all observations with weight 0. if (any(excl)) { ### If there are any observations to exclude res - res[!excl] ### then keep the ones with weight not zero N - length(res) w - w[!excl]} so the above chunk keeps only the residuals and weights for the observations with non-zero weights } N0 - N if (REML) N - N - p val - 0.5 * (sum(log(w)) - N * (log(2 * pi) + 1 - log(N) + log(sum(w * res^2 so now there are no more observations with w == 0 in the above equation if (REML) val - val - sum(log(abs(diag(object$qr$qr)[1:p]))) attr(val, nall) - N0 attr(val, nobs) - N attr(val, df) - p + 1 class(val) - logLik val } Best, Dana -- View this message in context: http://www.nabble.com/Help-with-reading- code-tp20823979p20823979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. Steven McKinney Statistician Molecular Oncology and Breast Cancer Program British Columbia Cancer Research Centre email: [EMAIL PROTECTED] tel: 604-675-8000 x7561 BCCRC Molecular Oncology 675 West 10th Ave, Floor 4 Vancouver B.C. V5Z 1L3 Canada __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with maps
aha!, thanks for this. Avram On Dec 2, 2008, at 5:38 PM, Ray Brownrigg wrote: On Wed, 03 Dec 2008, Ray Brownrigg wrote: The easiest way would be: map('world', regions=UK, xlim=c(-10, 5), ylim=c(48, 60)) But of course: map('world', regions=c(UK, Ireland), xlim=c(-10, 5), ylim=c(48, 60)) might be more appropriate. HTH Ray Brownrigg MSCS, Victoria University of Wellington __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] XML-RPC
Hi Stavros httpRequest is good. You might also look at the RCurl package for access to more protocols and slightly higher level facilities for dealing with HTTP (and other) requests. Also, you might look at SSOAP as a related technology. I'll be interested to see what you come up with, so please let me know. D. Stavros Macrakis wrote: It looks like the xml and httpRequest libraries provide the necessary building blocks for writing an XML-RPC client. Has anyone done this? I'd like to benefit from your experience (or code!). Thanks, -s __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Howto Add Labels Next To Markers in Scatter Plot
Dear all, How can I plot the data below with scatter plot so that the next to the marker it contain the label for species __DATA__ class true_hits false_hits species big 2350180 lion big 375 20 dog big 635 97 cow big78 4 horse big 694 93 giraffe I am stuck with the following construct: dat -read.delim(mydata_data.txt) rl - dat[dat$class%in%big,] plot(rl$true_hits,rl$false_hits, pch=pch_list[[big]], xlab=# True Hits, ylab=# False Hits,bg=red) - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Discrimination vs. Calibration for newbies?
Hi there, I can't seem to wrap my head around the differences between discrimination and calibration. I think that I learn best by examples. Could someone provide me with detailed explanations using examples of when a model could do both well, both poorly, and one well and the other poorly? Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Logistic Regression: variable selection based on p value?
Hi, When I use logistic regression, each variable has a p value associated with it. Do I only include the variables that have a statistically significant p value (0.05), or are there situations when I should include variables when their p values are high? I had heard that if a variable has a high p value but it's not the terminal variable, keep it; otherwise, take it out. Not sure if it's right or even why this is the case. What about if my p values are terrible but this combo of variables yields the highest AUC and calibration? What prevails in this case? Thank you! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] readAsciiGrid memory issues
Hi List, I am unable to read in a 7.8Gb ascii grid using readAsciiGrid {maptools} - R runs out of memory. I have 4Gb ram and 4Gb swap, so things are getting tight. I am wondering if anyone has alternative options (preferably with example) that enable to read in large grids, do some calculations and save a new grid? I am running linux 64bit on opensuse11 and R 2.8.0 Thanx Herry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Post Hoc methods for anova in R
Dear R community Does anyone know of some methods already programmed up open source in R for the post hoc methods in anova. I have some microarray data generated from different drug treatments 8 in particular, and a subset of 90 genes which i would like to analyseusing the above method. Thank you Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.