[R] Converting a Matrix to a Vector
Say I have: > set.seed( 1 ) > m <- matrix( runif(5^2), nrow=5, dimnames = list( c("A","B","C","D","E"), > c("O","P","Q","R","S") ) ) > m O P Q R S A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 B 0.3721239 0.94467527 0.1765568 0.7176185 0.2121425 C 0.5728534 0.66079779 0.6870228 0.9919061 0.6516738 D 0.9082078 0.62911404 0.3841037 0.3800352 0.121 E 0.2016819 0.06178627 0.7698414 0.7774452 0.2672207 --- I want to create a vector v from matrix m that looks like this: A.O 0.2655087 B.O 0.3721239 v <- as.vector( m ) almost gives me what I want, but then I need to take combinations of colnames( m ) and rownames( m ) to get my labels and hope they match up in order: if not, manipulate the order. This approach feels kludgy... Is this the right approach or is there a better way? -- View this message in context: http://www.nabble.com/Converting-a-Matrix-to-a-Vector-tp22696267p22696267.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] how to identify a symbol is defined from which package
hong shen yahoo.com> writes: > > I encountered a situation that a data frame is defined by two packages. Both of them are loaded by library(). > 2. If I want to reference the data frame from package A insted of B, how can I do it? Either change the loading sequence of library(). Or, if you want both, use library(a) aFrame = theFrame library(b) bFrame = the Frame # This step not really required Dieter __ 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] Interpolate x from y
Is it possible to interpolate a value for x with knowledge of y? For example, approx(x, y, xout) will give me y's given a set of x's, which is opposite to what I'm after. I've tried switching x and y, e.g., approx(y, x, xout), but in a real data set it is possible to have more than one y for a given x causing approx() to remove coordinates. Thanks for your help, Greg. __ 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] Install local binary package on a Mac
Dear readers, I would like to install a local binary package (.tar file) on a Mac (OSX 10.5.6) with R 2.8.0... I tried : mypkgdir = "/Users/philippesaner/Desktop/Rpkgs" install.packages("R2WinBUGS_2.1-12.tar", destdir = mypkgdir, lib = "/Library/Frameworks/R.framework/Resources/library", repos=NULL) and get the following error message: tar (child): R2WinBUGS_2.1-12.tar: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error exit delayed from previous errors Fehler in sprintf(gettext(fmt, domain = domain), ...) : Argument fehlt ohne Standard Can anyone suggest what I am doing wrong? Thanks a lot for help, Philippe -- View this message in context: http://www.nabble.com/Install-local-binary-package-on-a-Mac-tp22695133p22695133.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] Converting a Matrix to a Vector
try this: set.seed(1) m <- matrix(runif(5^2), nrow = 5, dimnames = list(c("A","B","C","D","E"), c("O","P","Q","R","S"))) v <- c(m) names(v) <- paste(rownames(m), colnames(m)[col(m)], sep = ".") # or # names(v) <- outer(rownames(m), colnames(m), paste, sep = ".") v I hope it helps. Best, Dimitris Ken-JP wrote: Say I have: set.seed( 1 ) m <- matrix( runif(5^2), nrow=5, dimnames = list( c("A","B","C","D","E"), c("O","P","Q","R","S") ) ) m O P Q R S A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 B 0.3721239 0.94467527 0.1765568 0.7176185 0.2121425 C 0.5728534 0.66079779 0.6870228 0.9919061 0.6516738 D 0.9082078 0.62911404 0.3841037 0.3800352 0.121 E 0.2016819 0.06178627 0.7698414 0.7774452 0.2672207 --- I want to create a vector v from matrix m that looks like this: A.O 0.2655087 B.O 0.3721239 v <- as.vector( m ) almost gives me what I want, but then I need to take combinations of colnames( m ) and rownames( m ) to get my labels and hope they match up in order: if not, manipulate the order. This approach feels kludgy... Is this the right approach or is there a better way? -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University 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] how to calcualte Jaccard Coefficient
You could try 'vegdist()' in the 'vegan' package. Greg. On Mar 24, 11:30 pm, Wen Gu wrote: > Does anyone have a good method for calculating Jaccard coefficients now that > the dissimilarity() function is no longer an option? > > Wen Gu > > John Jay College of Criminal Justice445 West 59 StreetNew York, NY 10029 > w...@gc.cuny.edu > > _ > Express your personality in color! Preview and select themes for Hotmail®. > > GTX_WL_HM_express_032009#colortheme > [[alternative HTML version deleted]] > > __ > r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://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] command to start a program (fortran code)
Hello! Does exist a command to start a foreign program (Fortran language)? I wrote a few r-scripts in which data are prepared and several outputfiles are generated that are used as inputfiles for further calculation. For these calculations another program is needed, so it would be practically if I could get the program started automatically after the preparation of the data has finished. (The program just opens a new window which asks you to put in some parameters an give the names of the inputfiles. Afterwards it generats some outputfiles that are stored in the same folder as the inputfiles.) The aim is, that the user has just to use R to run the whole application. Thanks" - Tamara Hoebinger University of Vienna -- View this message in context: http://www.nabble.com/command-to-start-a-program-%28fortran-code%29-tp22696214p22696214.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] Converting a Matrix to a Vector
G'day Ken, On Wed, 25 Mar 2009 00:13:48 -0700 (PDT) Ken-JP wrote: > > Say I have: > > > set.seed( 1 ) > > m <- matrix( runif(5^2), nrow=5, dimnames = > > list( c("A","B","C","D","E"), c("O","P","Q","R","S") ) ) > > m > O P Q R S > A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 > B 0.3721239 0.94467527 0.1765568 0.7176185 0.2121425 > C 0.5728534 0.66079779 0.6870228 0.9919061 0.6516738 > D 0.9082078 0.62911404 0.3841037 0.3800352 0.121 > E 0.2016819 0.06178627 0.7698414 0.7774452 0.2672207 > > --- > > I want to create a vector v from matrix m that looks like this: > > A.O 0.2655087 > B.O 0.3721239 > > v <- as.vector( m ) almost gives me what I want, but then I need to > take combinations of colnames( m ) and rownames( m ) to get my labels > and hope they match up in order: if not, manipulate the order. This > approach feels kludgy... > > Is this the right approach or is there a better way? R> tt <- reshape(data.frame(m), direction="long", varying=list(1:5), ids=rownames(m), times=colnames(m)) R> ind <- names(tt) %in% c("time", "id") R> uu <- tt[,!ind] R> names(uu) <- rownames(tt) R> uu A.OB.OC.OD.OE.OA.PB.P 0.26550866 0.37212390 0.57285336 0.90820779 0.20168193 0.89838968 0.94467527 C.PD.PE.PA.QB.QC.QD.Q 0.66079779 0.62911404 0.06178627 0.20597457 0.17655675 0.68702285 0.38410372 E.QA.RB.RC.RD.RE.RA.S 0.76984142 0.49769924 0.71761851 0.99190609 0.38003518 0.77744522 0.93470523 B.SC.SD.SE.S 0.21214252 0.65167377 0.1210 0.26722067 HTH. Cheers, Berwin === Full address = Berwin A TurlachTel.: +65 6516 4416 (secr) Dept of Statistics and Applied Probability+65 6516 6650 (self) Faculty of Science FAX : +65 6872 3919 National University of Singapore 6 Science Drive 2, Blk S16, Level 7 e-mail: sta...@nus.edu.sg Singapore 117546http://www.stat.nus.edu.sg/~statba __ 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] multiple paired t-tests
Perfect. In conjunction with Jorge's contrib that works a treat. Thanks. Dan On Tue, 2009-03-24 at 19:00 -0400, David Winsemius wrote: > ?try > ?tryCatch __ 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] mvtnorm package
Dear all, I would like to ask information about the package mvtnorm in R. It is very useful for me the "qmvnorm" comand, but I see that it can compute only quantile for equicoordinate. Is it possible to have a curve (or a set of values) if we don't want equicoordinates? Thank you Best regards Antonio. -- Antonio Lucadamo, Dipartimento di Scienze Economiche e Metodi Quantitativi Università del Piemonte Orientale "A. Avogadro" via Perrone, 18 - 28100 Novara fax: +39 0321 375305 phone:+39 0321 375338 mobile phone: +39 3385973881 skype contact: antonio.lucadamo __ 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] calculate the power of kendall or spearman correlation
Hi, I am searching for a way to calculate the power of a Spearman or Kendall correlation analysis over a range of effect values. Is there any way I can do this with R? thanks for the help. -- View this message in context: http://www.nabble.com/calculate-the-power-of-kendall-or-spearman-correlation-tp22696719p22696719.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] [ggplot2] Densityplot, grouping and NAs
Dear Bernd, Omitting the NA values from the dataset will work. ggplot(aes(x = x, color = g), data = na.omit(mydf)) + geom_density() Notice that I have omitted the group argument. It is redundant in this case. 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 thierry.onkel...@inbo.be 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Weiss, Bernd Verzonden: woensdag 25 maart 2009 7:36 Aan: r-help@r-project.org Onderwerp: [R] [ggplot2] Densityplot, grouping and NAs Dear all, I do not fully understand how ggplot2 handles NAs. See the following example: library(ggplot2) x <- rnorm(150) g <- as.factor(c(rep(c(0,1,NA),50))) mydf <- data.frame(x,g) m <- ggplot(aes(x = x, group = g, color = g), data = mydf) m + geom_density() How do I get rid of the NAs (i.e. the blue colored curve)? I thought ## m <- ggplot(aes(x = x, group = g, color = g, na.rm = TRUE), ## data = mydf) ## m + geom_density() or ## m <- ggplot(aes(x = x, group = g, color = g), data = mydf) ## m + geom_density() ## m + stat_density(na.rm = TRUE) etc. would solve my problem but to no avail. Thanks for your help, Bernd __ 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] multiple paired t-tests
so you want to find a needle in a haystack, not an easy task. You should account for multiple tests, which is as far as I can see not done in the code yet - or you have to accept that you find a bunch of hay which accidentally looks pretty much like a needle. There are some solutions in doing such things for instance finding relevant SNPs in microarray data. Maybe your task is quite similar. Eik Dan Kortschak schrieb: That is a valid point, the number of samples I expect to be different is actually quite small, but it is supportable (or otherwise) by other experimental data. Unfortunately the question I really want answered is pretty much covered by doing this. thanks Dan On 25/03/2009, at 10:25 AM, Eik Vettorazzi wrote: .. and you will end up - in your example- with 60 t-statistics and p-values (so you do bonforroni adjustment or something like that)?! Sometimes the question for "How do I ..." should be read as "What is the question I *really* want to be answered ...". You may consider doing some more sophisticated analysis. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ 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 calcualte Jaccard Coefficient
Greg gmail.com> writes: > > You could try 'vegdist()' in the 'vegan' package. > > Yep, you could. However, if you want to have Jaccard for binary data although your data are not binary, you must set binary = TRUE in vegan::vegdist. Indeed, the greatest problem with recommending Jaccard is that there is a huge number of packages that have this index, and you probably forget some of those in any recommendation. I think at least the following packages have Jaccard index: ade4, analogue, ecodist, labdsv and probably many more. Cheers, Jari Oksanen __ 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] multiple paired t-tests
I'm not really looking for a needle in a haystack, there are a small number of the 60 tests (about 20) that are likely to concord with other experiments I have, and in a particular pattern. Since I already have the data in tables for graphic depiction, I was hoping to have a reasonably easy way to find whether this way the case. It seems so. So it's not a matter of finding a needle in a haystack, but more finding a patch of embroidery that I know the pattern of. It still might be a woven bit of hay, but it's not as likely. Dan On Wed, 2009-03-25 at 10:04 +0100, Eik Vettorazzi wrote: > so you want to find a needle in a haystack, not an easy task. You should > account for multiple tests, which is as far as I can see not done in the > code yet - or you have to accept that you find a bunch of hay which > accidentally looks pretty much like a needle. > There are some solutions in doing such things for instance finding > relevant SNPs in microarray data. Maybe your task is quite similar. > Eik __ 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] modelling probabilities instead of binary data with logisticregression
Hi Joris, glm() handles proportions but will give you a warning (and not an error) about non-integer values. So if you get an error then there should be something wrong with the syntax, model or data. Can you provide us with a reproducible example? Cheers, 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 thierry.onkel...@inbo.be 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens joris meys Verzonden: dinsdag 24 maart 2009 20:30 Aan: R-help Mailing List Onderwerp: [R] modelling probabilities instead of binary data with logisticregression Dear all, I have a dataset where I reduced the dimensionality, and now I have a response variable with probabilities/proportions between 0 and 1. I wanted to do a logistic regression on those, but the function glm refuses to do that with non-integer values in the response. I also tried lrm, but that one interpretes the probabilities as different levels and gives for every level a different intercept. Not exactly what I want... Is there a way to specify that the response variable should be interpreted as a probability? Kind regards Joris [[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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] glm.nb() giving strongly different results
Thank you, Bill, for your answer! I am also at a total loss when looking for an explanation. I just can't remember what I did differently... At least the errors are confined to a rather small dataset so the repetition of all the glm.nb() analyses won't take much time. The only thing I found out so far is that the problem appeared at binary explanatory variables to which the full set of study participants contributed their answers, but the problem did not occur when analysing binary variables where only the employed people contributed to the dataset... Either employed people are some kind of magicians or I drank too little coffee to understand that I *really* did something different during my R work... Thanks again, David >From what you tell us it is impossible even to see if there is a problem, let alone what it might be if there is one. There are all kinds of reasons why intercepts may change and it is only unexpected if you do not fully understand what the intercept parameter really is. For example, if you change a predictor variable to have a different centre, x -> x-c, you will not change the regression coefficient with respect to x, but by varying c you can make the intercept anything you like. Literally. Anything. And this is nothing whatever to do with glm.nb, it applies equally to glm, lm, aov, ... I can console you on one point, though. glm.nb does not use a stochastic algorithm, and so no random numbers are involved. So unless you are generating fake data, the random number generator should play no part. Bill Venables http://www.cmis.csiro.au/bill.venables/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Croll Sent: Wednesday, 25 March 2009 12:36 PM To: r-help@r-project.org Subject: [R] glm.nb() giving strongly different results Dear colleagues, I have performed several dozens of glm.nb(response ~ variable) analyses weeks ago, and when I looked through the results today I saw that many of the results have quite different intercept values despite the response part remained the same. I'm quite sure I did same kind of analysis when the intercept values were around consistently around 2.2 and when they were above 3. When I repeated the analyses today, the intercept values were normal, they were between 2.1 to 2.3 instead of being above 3. I'm standing in front of a puzzle... they surely aren't glm() results, for they would give intercept values well above 9. Is there anything like a set.seed() thing that could have changed some properties inside R? On a second look, I discovered that the init.theta value is much lower in those analyses I have to perform again. Does anybody have a clue to this problem? It isn't that important that I have an answer (because I simply have to repeat the analyses), but still... 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-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] turning of html help
Hi I've just upgraded my version of R. I'm used to having the help pages turn up on a simple text window, and not html. Now it seems that when I call a help page it starts up a browser, and says it can't find the manual page(probably since I didn't install html help). I guess there is some option somewhere that turns of html help and goes back to the simple version. What is this, and how do I permanently enable it? I promise I did look around on the web for this but couldn't find the answer. Thanks Simon Bond [[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] Search "Errors"
On Tue, 2009-03-24 at 11:45 -0700, CE.KA wrote: > Hi R users, > I have a big program > So in Rgui I can t see all the execution of it > Is there a way to ask R if there is "Errors" in my program > Sincerely yours Hi Normally i use 3 functions in debug R routines: trace, browser and debug. In special cases i use a debug package ( http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf ) Article: Debugging without (too many) tears -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ 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] R Query
I am using R in C#. I installed R 2.8.1 and R-(D)Com R scilab DCOM3.0-1B5.exe. I got an error when i run the web application at the line where R is initilized as "System.Runtime.InteropServices.COMException was unhandled by user code Message="Exception from HRESULT: 0x80040013" Source="Interop.STATCONNECTORSRVLib" ErrorCode=-2147221485 StackTrace: at STATCONNECTORSRVLib.StatConnectorClass.Init(String bstrConnectorName) at _Default.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\177803\My Documents\Visual Studio 2005\WebSites\WebSite4\Default.aspx.cs:line 40 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)" Please help me in handling this error. Please give me a steps to install R and R-(D)Com and code to call R from C# to get boxplot graph as output in webpage by getting the input from user. Waiting for your reply. Thanks in advance. With Regards, Saraniya P [[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] Discreminant Analysis(How to interpret??)
I am trying to carry out discriminant analysis using the syntax: mydata.lda<-lda(Y~X+Z,data=mydata) and result that I am getting is Call: lda(Y ~ X + Z, data = mydata) Prior probabilities of groups: 0 1 0.3636364 0.6363636 Group means: XZ 0 17726.750 4020.00 1 2307.286 10100.86 Coefficients of linear discriminants: LD1 X -9.478517e-05 Z 2.817044e-06 Now my problem is how to interpret the result. Please help me out with the interpretation of the above discriminant analysis result. Thanks in advance -- View this message in context: http://www.nabble.com/Discreminant-Analysis%28How-to-interpret--%29-tp22698146p22698146.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] [ggplot2] Densityplot, grouping and NAs
ONKELINX, Thierry schrieb: Dear Bernd, Omitting the NA values from the dataset will work. ggplot(aes(x = x, color = g), data = na.omit(mydf)) + geom_density() Dear Thierry, thanks for your reply! Of course, regarding my little toy example na.omit() perfectly works. However, my real data set consists of hundreds of variables. So, one has to write ... data = na.omit(myHugeDataset[,c("var1","var99","var208")]) ... Bernd __ 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] Competing risks Kalbfleisch & Prentice method
Dear R users I would like to calculate the Cumulative incidence for an event adjusting for competing risks and adjusting for covariates. One way to do this in R is to use the cmprsk package, function crr. This uses the Fine & Gray regression model. However, a simpler and more classical approach would be to implement the Kalbfleisch & Prentice method (1980, p 169), where one fits cause specific cox models for the event of interest and each type of competing risk, and then calculates incidence based on the overall survival. I believe that this is what the cuminc function in the aforementioned package does, but it does not allow to adjust for a vector of covariates. My question is, is there an R package that implements the Kalbfleisch & Prentice method for competing risks with covariates? for example, if k1 is the cause of interest among k competing causes: P_k1(t; x)=P(T<=t, cause=k1|x)=Sum(u=0, ..., u=t) {hazard_k(u;x)*S(u;x)} where S(u;x) = exp{-sum_of_k(sum(hazard_k(u))} I have searched extensively for an implementation of this in many packages, but it appears that more complex approaches are more commonly implemented, such as timereg package. Eleni Rapsomaniki Research Associate Strangeways Research Laboratory Department of Public Health and Primary Care University of Cambridge [[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] Including greek letters in a pairs() plot
Good Morning, I have a stupid problem about inclusion of greek letters in a plot built with function pairs(). First of all, I have a matrix with 3 columns and 1000 rows and I would like to use pairs() in order to plot points in the upper panel and to compute correlation in the lower panel. In the lower panel I would like to see the following text in each ij-plot: hat(rho)[i,j]=cor(x,y). Obviously, rho should be written in according to greek alphabet. This is my function: panel.cor <- function(x,y){ cor<-0 cor<-round(cor(x,y),4) text (0.5,0.5,cor,cex=2) } Thank You very much, Enrico Foscolo __ 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] Densityplot, grouping and NAs
Dear Bernd, If only one variable is causing this problem you could make a subset on that variable. data = mydf[!is.na(mydf$g), ] 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 thierry.onkel...@inbo.be 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: Bernd Weiss [mailto:bernd.we...@uni-koeln.de] Verzonden: woensdag 25 maart 2009 11:10 Aan: ONKELINX, Thierry; r-help@r-project.org Onderwerp: Re: [R] [ggplot2] Densityplot, grouping and NAs ONKELINX, Thierry schrieb: > Dear Bernd, > > Omitting the NA values from the dataset will work. > > ggplot(aes(x = x, color = g), data = na.omit(mydf)) + geom_density() Dear Thierry, thanks for your reply! Of course, regarding my little toy example na.omit() perfectly works. However, my real data set consists of hundreds of variables. So, one has to write ... data = na.omit(myHugeDataset[,c("var1","var99","var208")]) ... Bernd Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] Interpolate x from y
Greg, it seems an obvious behavior to me y=c(2,2,2,3,3,3,1) x=1:length(y) plot(x,y) lines(x,approxfun(x,y)(x)) # for every x it exists one only value of y plot(y,x) lines(sort(y),approxfun(y,x)(sort(y))) # for some y it exists more than one value of x! approxfun return a function. By definition a function maps one value of domain into one only value of codomain. Would you expect that one y value returns more than one x? I don't Be more specific and maybe we can help you Patrizio 2009/3/25 Greg : > Is it possible to interpolate a value for x with knowledge of y? > > For example, approx(x, y, xout) will give me y's given a set of x's, > which is opposite to what I'm after. I've tried switching x and y, > e.g., approx(y, x, xout), but in a real data set it is possible to > have more than one y for a given x causing approx() to remove > coordinates. > > Thanks for your help, > > Greg. > > __ > 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 identify a symbol is defined from which package
hong shen wrote: Hi list, I encountered a situation that a data frame is defined by two packages. Both of them are loaded by library(). My questions are 1. How could I tell the data frame is from which package? find("theName") will tell you where it found a variable called theName. 2. If I want to reference the data frame from package A insted of B, how can I do it? A::theName or B::theName will find whichever one you want. Duncan Murdoch Thanks! hshen __ 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] Install local binary package on a Mac
PhilippeR wrote: Dear readers, I would like to install a local binary package (.tar file) on a Mac (OSX 10.5.6) with R 2.8.0... How did the package get created? .tar is not an extension used by R. (Source packages are .tar.gz on all platforms, binary packages are .tgz on Mac OS.) Duncan Murdoch I tried : mypkgdir = "/Users/philippesaner/Desktop/Rpkgs" install.packages("R2WinBUGS_2.1-12.tar", destdir = mypkgdir, lib = "/Library/Frameworks/R.framework/Resources/library", repos=NULL) and get the following error message: tar (child): R2WinBUGS_2.1-12.tar: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error exit delayed from previous errors Fehler in sprintf(gettext(fmt, domain = domain), ...) : Argument fehlt ohne Standard Can anyone suggest what I am doing wrong? Thanks a lot for help, Philippe __ 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] Green and Byar (1980) Prostate Cancer Data set from Andrews and Herzberg - Data
One further version: this one with a header and with NA's replacing the -'s that apparently has not deleted any cases with missing data: http://www.stat.auckland.ac.nz/~wild/764/s764data/prostatic.tab -- David Winsemius On Mar 24, 2009, at 11:51 PM, Ravi Varadhan wrote: Fine detective work, David. Now, you can see the reasons for my frustration - multiplicity of data sets combined with non-existent documentation of the source of data in journal articles (e.g. Kay 1986; Lunn and McNeil 1995). Best, Ravi. Ravi Varadhan, Ph.D. On Mar 24, 2009, at 8:57 PM, Rolf Turner wrote: On 25/03/2009, at 12:09 PM, Frank E Harrell Jr wrote: (2) Scrolling down to ``Byar and Green prostate cancer data'' appeared to get me to the right place. But I couldn't see any signs of any ``R binary files''. Please look again. It's under the heading "R". Unfortunately I used .sav suffix for save() files in the old days. Ah-ha. Oh me of little faith. I have been hanging around (in my current work environment) with too many SPSS users, and the *.sav extension seems to be the standard for SPSS data files. Whence my corrupted thinking. The .xls fine opened with no problem in OpenOffice; has 506 rows. Hmmm. When I opened it with Excel on the Mac I got a spread sheet with 503 rows --- the first row being the column names, so there were really 502 rows. The last "patnr" is "506" but there are only 502 lines of data. 471, 473, 475 and 488 are missing. And the CMU Statlib version for 2002 looks the same. The version at this site is missing more than 25 cases: Here are two other copies of the dataset the first of which appears to have those missing cases: This one has patient numbers: This one has a description of the fields and cites the one above but has not retained the patient numbers and has apparently only kept the 475 cases with complete data. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] mvtnorm package
If you needed to restrict yourself to mvtnorm you could simulate and get an estimate. If you were willing to look at other packages you could try the pmnorm function in mnormt. On Mar 25, 2009, at 4:00 AM, Antonio Lucadamo wrote: Dear all, I would like to ask information about the package mvtnorm in R. It is very useful for me the "qmvnorm" comand, but I see that it can compute only quantile for equicoordinate. Is it possible to have a curve (or a set of values) if we don't want equicoordinates? Thank you Best regards Antonio. Antonio Lucadamo, Dipartimento di Scienze Economiche e Metodi Quantitativi Università del Piemonte Orientale "A. Avogadro" David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] generalized Poisson regression
Arafat; You should listen to Umesh rather than myself on this point, and i should refrain from posting after my bedtime. I should have typed "glm". -- David Winsemius On Mar 25, 2009, at 12:37 AM, Umesh Srinivasan wrote: > Hi, > > Not exactly sure what you mean, but if you want to run a poisson > regression and then look at the coefficients, then this is what you > need: > > poisson.model <- glm(response ~ predictor, family = "poisson") > > summary(poisson.model) > > Will give you the intercept and slope. Since poisson regression uses > a log link to model data linearly, the coefficients are in the log > scale. > > Cheers, > Umesh > > On Wed, Mar 25, 2009 at 4:20 AM, David Winsemius > wrote: > Consider: gls with family="poisson" > > > > On Mar 24, 2009, at 1:26 PM, Arafat Ud Zaman wrote: > > Dear sir, > I want to know about R command for parameter estimation for > generalized > Poisson regression. > > yours faithfully > > Arafat Ud Zaman > 4th year(Hons) > Applied statistics > University of Dhaka > Mob- +8801715173176 > David Winsemius, MD Heritage Laboratories West Hartford, CT [[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] Converting a Matrix to a Vector
Use the 'reshape' package: > library(reshape) > melt(m) X1 X2 value 1 A O 0.26550866 2 B O 0.37212390 3 C O 0.57285336 4 D O 0.90820779 5 E O 0.20168193 6 A P 0.89838968 7 B P 0.94467527 8 C P 0.66079779 9 D P 0.62911404 10 E P 0.06178627 11 A Q 0.20597457 12 B Q 0.17655675 13 C Q 0.68702285 14 D Q 0.38410372 15 E Q 0.76984142 16 A R 0.49769924 17 B R 0.71761851 18 C R 0.99190609 19 D R 0.38003518 20 E R 0.77744522 21 A S 0.93470523 22 B S 0.21214252 23 C S 0.65167377 24 D S 0.1210 25 E S 0.26722067 > On Wed, Mar 25, 2009 at 3:13 AM, Ken-JP wrote: > > Say I have: > >> set.seed( 1 ) >> m <- matrix( runif(5^2), nrow=5, dimnames = list( c("A","B","C","D","E"), >> c("O","P","Q","R","S") ) ) >> m > O P Q R S > A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 > B 0.3721239 0.94467527 0.1765568 0.7176185 0.2121425 > C 0.5728534 0.66079779 0.6870228 0.9919061 0.6516738 > D 0.9082078 0.62911404 0.3841037 0.3800352 0.121 > E 0.2016819 0.06178627 0.7698414 0.7774452 0.2672207 > > --- > > I want to create a vector v from matrix m that looks like this: > > A.O 0.2655087 > B.O 0.3721239 > > v <- as.vector( m ) almost gives me what I want, but then I need to take > combinations of colnames( m ) and rownames( m ) to get my labels and hope > they match up in order: if not, manipulate the order. This approach feels > kludgy... > > Is this the right approach or is there a better way? > > > > -- > View this message in context: > http://www.nabble.com/Converting-a-Matrix-to-a-Vector-tp22696267p22696267.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. > -- 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] Converting a Matrix to a Vector
try also m <- matrix( runif(5^2), nrow=5, dimnames = Names<- list( c("A","B","C","D","E"), c("O","P","Q","R","S") ) ) data.frame(expand.grid(Names[[1]],Names[[2]]),as.numeric(m)) data.frame(code=outer(Names[[1]],Names[[2]],paste,sep=".")[1:25],num=as.numeric(m)) Patrizio 2009/3/25 jim holtman : > Use the 'reshape' package: > >> library(reshape) >> melt(m) > X1 X2 value > 1 A O 0.26550866 > 2 B O 0.37212390 > 3 C O 0.57285336 > 4 D O 0.90820779 > 5 E O 0.20168193 > 6 A P 0.89838968 > 7 B P 0.94467527 > 8 C P 0.66079779 > 9 D P 0.62911404 > 10 E P 0.06178627 > 11 A Q 0.20597457 > 12 B Q 0.17655675 > 13 C Q 0.68702285 > 14 D Q 0.38410372 > 15 E Q 0.76984142 > 16 A R 0.49769924 > 17 B R 0.71761851 > 18 C R 0.99190609 > 19 D R 0.38003518 > 20 E R 0.77744522 > 21 A S 0.93470523 > 22 B S 0.21214252 > 23 C S 0.65167377 > 24 D S 0.1210 > 25 E S 0.26722067 >> > > > On Wed, Mar 25, 2009 at 3:13 AM, Ken-JP wrote: >> >> Say I have: >> >>> set.seed( 1 ) >>> m <- matrix( runif(5^2), nrow=5, dimnames = list( c("A","B","C","D","E"), >>> c("O","P","Q","R","S") ) ) >>> m >> O P Q R S >> A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 >> B 0.3721239 0.94467527 0.1765568 0.7176185 0.2121425 >> C 0.5728534 0.66079779 0.6870228 0.9919061 0.6516738 >> D 0.9082078 0.62911404 0.3841037 0.3800352 0.121 >> E 0.2016819 0.06178627 0.7698414 0.7774452 0.2672207 >> >> --- >> >> I want to create a vector v from matrix m that looks like this: >> >> A.O 0.2655087 >> B.O 0.3721239 >> >> v <- as.vector( m ) almost gives me what I want, but then I need to take >> combinations of colnames( m ) and rownames( m ) to get my labels and hope >> they match up in order: if not, manipulate the order. This approach feels >> kludgy... >> >> Is this the right approach or is there a better way? >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/Converting-a-Matrix-to-a-Vector-tp22696267p22696267.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. >> > > > > -- > 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. > __ 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] Including greek letters in a pairs() plot
Hi Enrico, see ?plotmath and the examples example(plotmath) there you will find all you need for your task. hth. enrico.fosco...@libero.it schrieb: Good Morning, I have a stupid problem about inclusion of greek letters in a plot built with function pairs(). First of all, I have a matrix with 3 columns and 1000 rows and I would like to use pairs() in order to plot points in the upper panel and to compute correlation in the lower panel. In the lower panel I would like to see the following text in each ij-plot: hat(rho)[i,j]=cor(x,y). Obviously, rho should be written in according to greek alphabet. This is my function: panel.cor <- function(x,y){ cor<-0 cor<-round(cor(x,y),4) text (0.5,0.5,cor,cex=2) } Thank You very much, Enrico Foscolo __ 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. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ 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] Interpolate x from y
Forgive me for not being more clear. > Would you expect that one y > value returns more than one x? I don't No, I don't either. I want to know the value of that x, however. For example: x <- c(2.743, 3.019, 3.329, 3.583, 4.017) y <- c(0.000, 0.025, 0.025, 0.158, 1.000) I would like to know the value of x when y is 0.1 and 0.9. If I try to "trick" approx() to give the answer I'm looking for by switching x & y (e.g., approx(y, x)) the (perfectly reasonable) warning, "In approx(y, x, c(0.1, 0.9)) : collapsing to unique 'x' values" is thrown. I'm simply wondering if it's possible to interpolate to an x-axis-- similar to approx()'s behaviour to interpolate to a y-axis, but in reverse. Greg. __ 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] Green and Byar (1980) Prostate Cancer Data set from Andrews and Herzberg - Data
Rolf Turner wrote: On 25/03/2009, at 12:09 PM, Frank E Harrell Jr wrote: (2) Scrolling down to ``Byar and Green prostate cancer data'' appeared to get me to the right place. But I couldn't see any signs of any ``R binary files''. Please look again. It's under the heading "R". Unfortunately I used .sav suffix for save() files in the old days. Ah-ha. Oh me of little faith. I have been hanging around (in my current work environment) with too many SPSS users, and the *.sav extension seems to be the standard for SPSS data files. Whence my corrupted thinking. It definitely is a standard for SPSS, that's why I regret ever using that suffix. The .xls fine opened with no problem in OpenOffice; has 506 rows. Hmmm. When I opened it with Excel on the Mac I got a spread sheet with 503 rows --- the first row being the column names, so there were really 502 rows. And 502 rows was what I got when I saved the *.xls file as a *.csv file and then read that in. Also, when I followed Phil Spector's excellent advice and loaded prostate.sav from the website, using load(), I ***again*** got a data frame of 502 rows. This data frame is (modulo some classes and attributes) identical with what I got from reading from the *.csv file. Sorry about that - I was looking at patient numbers. I do get 502 rows either with load()'ing the binary data frame or opening the spreadsheet. Where have the other four rows gone? Ravi Varadhan also observed this phenomenon. cheers, Rolf ## Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com ## -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] factor with numeric names
Thank you so much both for the answer. I think I have a better handle on this now. Yes, Loblolly$Seed is an ordered factor, but I didn't realize that the default for ordered factor is contr.poly. And then I was further confused because I didn't realize the coefficient names generated (not just the model) are different depending on whether there is an intercept term (even though they were both "contr.poly"). > lm(formula = height ~ age + Seed, data = Loblolly) Call: lm(formula = height ~ age + Seed, data = Loblolly) Coefficients: (Intercept) age Seed.L Seed.Q Seed.C Seed^4 -1.31240 2.59052 4.86941 0.87307 0.37894 -0.46853 Seed^5 Seed^6 Seed^7 Seed^8 Seed^9 Seed^10 0.55237 0.39659 -0.06507 0.35074 -0.83442 0.42085 Seed^11 Seed^12 Seed^13 0.53906 -0.29803 -0.77254 > lm(formula = height ~ age + Seed - 1, data = Loblolly) Call: lm(formula = height ~ age + Seed - 1, data = Loblolly) Coefficients: age Seed329 Seed327 Seed325 Seed307 Seed331 Seed311 Seed315 Seed321 2.5905 -3.3635 -3.0701 -1.7535 -2.3485 -2.6568 -2.0235 -1.3168 -2.4651 Seed319 Seed301 Seed323 Seed309 Seed303 Seed305 -0.7951 -0.4301 -0.1235 0.1049 0.4299 1.4382 This should have been obvious to me... (for the sake of completeness) I think factor() doesn't change the "ordered-ness" # as.factor(Loblolly$Seed) doesn't remove the ordered-ness > str(Loblolly$Seed) Ord.factor w/ 14 levels "329"<"327"<"325"<..: 10 10 10 10 10 10 13 13 13 13 ... > str(as.factor(Loblolly$Seed)) Ord.factor w/ 14 levels "329"<"327"<"325"<..: 10 10 10 10 10 10 13 13 13 13 ... # this works though > str(factor(Loblolly$Seed, ordered=F)) Factor w/ 14 levels "329","327","325",..: 10 10 10 10 10 10 13 13 13 13 ... Saiwing On Mar 21, 2009, at 3:35 PM, John Fox wrote: Dear Saiwing Yeung, You appear to be using orthogonal-polynomial contrasts (generated by contr.poly) for Seed, which suggests that Seed is either an ordered factor or that you've assigned these contrasts to it. Because Seed has 14 levels, you end up fitting an degree-13 polynomial. If Seed is indeed an ordered factor and you want to use contr.treatment instead then you could, e.g., set Loblolly$Seed <- as.factor(Loblolly$Seed). (If I'm right about Seed being an ordered factor, your solution worked because it changed Seed to a factor, not because it used non-numeric level names.) I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Saiwing Yeung Sent: March-21-09 5:02 PM To: r-help@r-project.org Subject: [R] factor with numeric names Hi all, I have a pretty basic question about categorical variables but I can't seem to be able to find answer so I am hoping someone here can help. I found that if the factor names are all in numbers, fitting the model in lm would return labels that are not very recognizable. # Example: let's just assume that we want to fit this model fit <- lm(height ~ age + Seed, data=Loblolly) # See the category names are all mangled up here fit Call: lm(formula = height ~ age + Seed, data = Loblolly) Coefficients: (Intercept) age Seed.L Seed.Q Seed.C Seed^4 -1.31240 2.59052 4.86941 0.87307 0.37894 -0.46853 Seed^5 Seed^6 Seed^7 Seed^8 Seed^9 Seed^10 0.55237 0.39659 -0.06507 0.35074 -0.83442 0.42085 Seed^11 Seed^12 Seed^13 0.53906 -0.29803 -0.77254 One possible solution I found is to rename the categorical variables seed.str <- paste("S", Loblolly$Seed, sep="") seed.str <- factor(seed.str) fit <- lm(height ~ age + seed.str, data=Loblolly) fit Call: lm(formula = height ~ age + seed.str, data = Loblolly) Coefficients: (Intercept) age seed.strS303 seed.strS305 seed.strS307 -0.43012.59050.86001.8683 -1.9183 seed.strS309 seed.strS311 seed.strS315 seed.strS319 seed.strS321 0.5350 -1.5933 -0.8867 -0.3650 -2.0350 seed.strS323 seed.strS325 seed.strS327 seed.strS329 seed.strS331 0.3067 -1.3233 -2.6400 -2.9333 -2.2267 Now it is actually possible to see which one is which, but is kind of lame. Can someone point me to a more elegant solution? Thank you so much. Saiwing Yeung __ 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-
Re: [R] Including greek letters in a pairs() plot
enrico.fosco...@libero.it wrote: Good Morning, I have a stupid problem about inclusion of greek letters in a plot built with function pairs(). First of all, I have a matrix with 3 columns and 1000 rows and I would like to use pairs() in order to plot points in the upper panel and to compute correlation in the lower panel. In the lower panel I would like to see the following text in each ij-plot: hat(rho)[i,j]=cor(x,y). Obviously, rho should be written in according to greek alphabet. This is my function: panel.cor <- function(x,y){ cor<-0 cor<-round(cor(x,y),4) text (0.5,0.5,cor,cex=2) } Example: panel.cor <- function(x,y){ cor <- round(cor(x,y),4) plot.window(0:1, 0:1) text(0.5, 0.5, substitute(hat(rho)[list(i,j)] == cor, list(cor=cor)), cex=1.2) } pairs(iris, lower.panel = panel.cor) Thank You very much, Enrico Foscolo __ 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] turning of html help
simon bond wrote: Hi I've just upgraded my version of R. I'm used to having the help pages turn up on a simple text window, and not html. Now it seems that when I call a help page it starts up a browser, and says it can't find the manual page(probably since I didn't install html help). I guess there is some option somewhere that turns of html help and goes back to the simple version. What is this, and how do I permanently enable it? I promise I did look around on the web for this but couldn't find the answer. See ?options on how to enable / disable help systems and ?Startup on how to do it each time on startup. Uwe Ligges Thanks Simon Bond [[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] command to start a program (fortran code)
If you want to integrate Fortran into R, see the manual Writing R Extensions. If you want to just call some external program (independent of the language it is written in) via the operating system, see ?system (and ?shell on Windows). Uwe Ligges thoeb wrote: Hello! Does exist a command to start a foreign program (Fortran language)? I wrote a few r-scripts in which data are prepared and several outputfiles are generated that are used as inputfiles for further calculation. For these calculations another program is needed, so it would be practically if I could get the program started automatically after the preparation of the data has finished. (The program just opens a new window which asks you to put in some parameters an give the names of the inputfiles. Afterwards it generats some outputfiles that are stored in the same folder as the inputfiles.) The aim is, that the user has just to use R to run the whole application. Thanks" - Tamara Hoebinger University of Vienna __ 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] position weight matrix
Bogdan Tanasa wrote: Hi all, I am sorry to fill your inbox mail with a naive question, although I would really appreciate your opinion. I am looking for a R function that takes a set of aligned sequences, and transforms a position frequency matrix into a position weight matrix. Thanks a lot. Is it well known what this terminology means in statistics? I have missed it so far and do not know which matrices you are talking about. You may want to be more specific and if this is about genetics, you may consider to ask on the BioConductor mailing list. Best, Uwe Ligges -- bogdan [[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] Merging rows in dataframes
Thank you, your answer was extremely helpful. One last problem though: one of the aggregate functions I'd like to apply on the columns is concatentation (equivalent to the paste() function). So if I have a given character column in three separate rows sharing the same ids with the value "apple" in the first, "banana" in the second, and "orange" in the third, in the summarizing row I'd like to receive output in the form "apple|banana|orange". Is there any way to do this? Thanks again, Schragi -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Tuesday, March 24, 2009 12:50 AM To: Schraga Schwartz Cc: r-help@r-project.org Subject: Re: [R] Merging rows in dataframes Using sqldf you only need two statements, infile <- file(...) and DF <- sqldf("select min(a), max(b), mean(c), ... from infile group by id"). The file statement identifies the filename and the second reads it into sqlite (without going through R), summarizes it and then reads the summarized version into R. You may also need to provide info on its format if its not in the default format. See example 4a on home page and the other examples there: http://sqldf.googlecode.com On Mon, Mar 23, 2009 at 5:58 PM, Schraga Schwartz wrote: > Hello, > > I have a dataframe with 40 columns and around 450,000 rows. The first column > in each row is a factor id and the remaining are numeric. Some rows have the > same ids. What I want to do is to merge each set of rows sharing the same > ids (id set) into one single row (summarizing row) with that id. To create > the summarizing row, I'd like to apply a different function on each of the > original columns in the id set. Some columns within the summarizing row will > equal the mean of the columns in the id set, others will equal the minimum, > others the maximum. > > To do this, I tried using the by() function. However, this was extremely > slow (it ran for more than two hours before I stopped it). Also, it used up > all of 16 GB of memory on my machine. Is there any more efficient function, > both in terms of time and memory, to do this sort of thing? > > Thank you very much, > Schraga 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@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] segfault when running heatmap()
- Does it still happen with R-2.9.0 alpha? - If so, can you please send us reproducible code in order to make able to see the error on our systems? Best wishes, uwe Ligges Andrew Yee wrote: Hi, I was wondering if someone in the mailing list has any insight into this segfault error that I consistently find when running a script containing heatmap() in R 2.8.1 and 2.8.0 on a Linux 64-bit machine. Some points: 1. This occurs when running heatmap(). 2. Interestingly, if I source() the script or copy and paste the script in its entirety, this error occurs. However, if I run the commands individually, heatmap() will actually work. 3. I've had this error occur on two types of machines as follows. Intel 64bit, linux kernel 2.6.18-92.1.22.el5, gcc version 4.1.2 as well as AMD 64bit, linux kernel 2.6.9-5.ELsmp, gcc version 3.4.3 Here is the error messages that I receive when I debug(heatmap) and source() the script containing heatmap(). The sessionInfo() follows. Browse[1]> debug: op <- par(no.readonly = TRUE) Browse[1]> *** caught segfault *** address 0x103c93d53, cause 'memory not mapped' Traceback: 1: function (display = "", width, height, pointsize, gamma, bg, canvas, fonts, xpos, ypos, title, type, antialias) {if (display == "" && .Platform$GUI == "AQUA" && is.na(Sys.getenv("DISPLAY", NA))) Sys.setenv(DISPLAY = ":0")new <- list()if (!missing(display)) new$display <- displayif (!missing(width)) new$width <- width if (!missing(height)) new$height <- heightif (!missing(gamma)) new$gamma <- gammaif (!missing(pointsize)) new$pointsize <- pointsizeif (!missing(bg)) new$bg <- bg if (!missing(canvas)) new$canvas <- canvasif (!missing(xpos)) new$xpos <- xposif (!missing(ypos)) new$ypos <- yposif (!missing(title)) new$title <- titleif (!checkIntFormat(new$title)) stop("invalid 'title'")if (!missing(type)) new$type <- match.arg(type, c("Xlib", "cairo", "nbcairo"))if (!missing(antialias)) {new$antialias <- pmatch(antialias, c("default", "none", "gray", "subpixel")) if (is.na(new$antialias)) stop("invalid value for 'antialias'")}d <- check.options(new, name.opt = ".X11.Options", envir = .X11env)type <- if (capabilities("cairo")) switch(d$type, cairo = 1, nbcairo = 2, 0)else 0if (display == "XImage") type <- 0.Internal(X11(d$display, d$width, d$height, d$pointsize, d$gamma, d$colortype, d$maxcubesize, d$bg, d$canvas, d$fonts, NA_integer_, d$xpos, d$ypos, d$title, type, d$antialias))}() 2: par(no.readonly = TRUE) 3: heatmap(selected.matrix, distfun = cor.dist, zlim = zlim, col = colors.for.heatmap) 4: eval.with.vis(expr, envir, enclos) 5: eval.with.vis(ei, envir) Here is the sessionInfo() sessionInfo() R version 2.8.1 (2008-12-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] tools grid stats graphics grDevices utils datasets [8] methods base other attached packages: [1] u133x3p.db_2.2.5RSQLite_0.7-1 DBI_0.2-4 [4] AnnotationDbi_1.4.3 Biobase_2.2.2 vcd_1.2-3 [7] colorspace_1.0-0MASS_7.2-46 Thanks, Andrew [[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] Green and Byar (1980) Prostate Cancer Data set from Andrews and Herzberg - Data
Ravi Varadhan wrote: Fine detective work, David. Now, you can see the reasons for my frustration - multiplicity of data sets combined with non-existent documentation of the source of data in journal articles (e.g. Kay 1986; Lunn and McNeil 1995). Best, Ravi. Yes that is a big frustration for me, even for projects for which I was the principal statistician in 1990 for which I did a poor job of archiving excellent medical datasets for future use. This is a big advertisement for the reproducible research movement. David - fantastic job. Based on what you found, the version on our web site looks as good as any. Now if someone can explain to me why you see a spike near a serum prostate acid phosphatase (AP) value of 1 when you use a flexible regression model (e.g., restricted cubic spline) to relate AP to the log hazard of death in a survival model (see p. 518 in my book), that would be very helpful. If you do with(prostate,plot(supsmu(log(ap),1*(status!='alive' you see a minimum at ap=2.37 after anti-logging. If you do dd <- datadist(prostate); options(datadist='dd') f <- cph(Surv(dtime,status!='alive') ~ rcs(log(ap),6), data=prostate) plot(f) you see a sharp minimum at ap=1.43. With 4 knots the min is a 1.18. You have to go to 3 knots to get a monotonic fit in log(ap) but AIC is not as good. Frank Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: David Winsemius Date: Tuesday, March 24, 2009 10:54 pm Subject: Re: [R] Green and Byar (1980) Prostate Cancer Data set from Andrews and Herzberg - Data To: Rolf Turner Cc: R-help Forum , Ravi Varadhan On Mar 24, 2009, at 8:57 PM, Rolf Turner wrote: > > On 25/03/2009, at 12:09 PM, Frank E Harrell Jr wrote: > > > >>> (2) Scrolling down to ``Byar and Green prostate cancer data'' >>> appeared >>> to get >>> me to the right place. But I couldn't see any signs of any ``R >>> binary >>> files''. >> >> Please look again. It's under the heading "R". Unfortunately I used >> .sav suffix for save() files in the old days. > > Ah-ha. Oh me of little faith. I have been hanging around (in > my current work environment) with too many SPSS users, and the > *.sav extension seems to be the standard for SPSS data files. > Whence my corrupted thinking. > >> The .xls fine opened with no problem in OpenOffice; has 506 rows. > > Hmmm. When I opened it with Excel on the Mac I got a spread > sheet with 503 rows --- the first row being the column names, > so there were really 502 rows. The last "patnr" is "506" but there are only 502 lines of data. 471, 473, 475 and 488 are missing. And the CMU Statlib version for 2002 looks the same. The version at this site is missing more than 25 cases: Here are two other copies of the dataset the first of which appears to have those missing cases: This one has patient numbers: This one has a description of the fields and cites the one above but has not retained the patient numbers and has apparently only kept the 475 cases with complete data. > David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] Doing %o% that operates on columns instead of atomics
Okay, this one is hard to put into words: > x <- 1:9; names(x) <- x > y <- x %o% x > y 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 2 2 4 6 8 10 12 14 16 18 3 3 6 9 12 15 18 21 24 27 4 4 8 12 16 20 24 28 32 36 5 5 10 15 20 25 30 35 40 45 6 6 12 18 24 30 36 42 48 54 7 7 14 21 28 35 42 49 56 63 8 8 16 24 32 40 48 56 64 72 9 9 18 27 36 45 54 63 72 81 > my.foo( a, b ) { c <- a - b; #really more complex, but just to illustrate > } - What I would like to do is apply my.foo() which takes two columns, a and b, does an operation and returns another column c. The columns I want to feed into my.foo() are all the combinations of columns in y. So I want to apply my.foo( y[,1], y[,1] ) and then my.foo( y[,1], y[,2] ), etc... for all combinations() of the 10 columns in y. I would expect the final output to be 10x10x10. Passing 10 columns by 10 columns to my.foo() which outputs a vector of 10 numbers at a time. ***So in essence, what I am trying to accomplish is like outer(), but instead of operating on atomic values, I want to operate on columns of y. I know I can use loops to accomplish this, but I would like to code as R-like as possible. I am learning a great deal about "how to think in R" from the excellent replies on this board. Thanks in advance for any suggestions. -- View this message in context: http://www.nabble.com/Doing--o--that-operates-on-columns-instead-of-atomics-tp22701363p22701363.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] Doing %o% that operates on columns instead of atomics
CORRECTION: > my.foo <- function( a, b ) { c <- a - b; } #really more complex, but just > to illustrate -- View this message in context: http://www.nabble.com/Doing--o--that-operates-on-columns-instead-of-atomics-tp22701363p22701400.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] Merging rows in dataframes
In the Links box to the right on the sqldf home page click on "SQLite - aggregate functions" and lookup group_concat. On Wed, Mar 25, 2009 at 9:05 AM, Schragi Schwartz wrote: > Thank you, your answer was extremely helpful. One last problem though: one > of the aggregate functions I'd like to apply on the columns is > concatentation (equivalent to the paste() function). So if I have a given > character column in three separate rows sharing the same ids with the value > "apple" in the first, "banana" in the second, and "orange" in the third, in > the summarizing row I'd like to receive output in the form > "apple|banana|orange". Is there any way to do this? > > Thanks again, > Schragi > > -Original Message- > From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] > Sent: Tuesday, March 24, 2009 12:50 AM > To: Schraga Schwartz > Cc: r-help@r-project.org > Subject: Re: [R] Merging rows in dataframes > > Using sqldf you only need two statements, infile <- file(...) and > DF <- sqldf("select min(a), max(b), mean(c), ... from infile group by id"). > The file statement identifies the filename and the second reads it > into sqlite (without > going through R), summarizes it and then reads the summarized version > into R. You may also need to provide info on its format if its not in the > default format. See example 4a on home page and the other examples > there: > http://sqldf.googlecode.com > > > On Mon, Mar 23, 2009 at 5:58 PM, Schraga Schwartz > wrote: >> Hello, >> >> I have a dataframe with 40 columns and around 450,000 rows. The first > column >> in each row is a factor id and the remaining are numeric. Some rows have > the >> same ids. What I want to do is to merge each set of rows sharing the same >> ids (id set) into one single row (summarizing row) with that id. To create >> the summarizing row, I'd like to apply a different function on each of the >> original columns in the id set. Some columns within the summarizing row > will >> equal the mean of the columns in the id set, others will equal the > minimum, >> others the maximum. >> >> To do this, I tried using the by() function. However, this was extremely >> slow (it ran for more than two hours before I stopped it). Also, it used > up >> all of 16 GB of memory on my machine. Is there any more efficient > function, >> both in terms of time and memory, to do this sort of thing? >> >> Thank you very much, >> Schraga 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@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] Angstrom Symbol on Y-axis ?
Hi, I have started very recently with R in order to get excellent Box and Whisker plots. I could plot my data nicely. However, I can't figure out from R-mailing list archive or google search either, how to place an Angstrom sign/symbol on the y-axis (any axis in principle), after a usual y-axis label ? I am doing something like this: boxplot(MAE.0_6,MAE.7_12,MAE.13_20,MAE.21_40,MAE.41_100,MAE. 101_200,MAE.201_300,MAE. 301_400 ,cex .lab = 0.80 ,names = c ("0 -6 ","7 -12 ","13 -20 ","21 -40","41-100","101-200","201-300","301-400"),cex.axis=0.70,col="gold", xlab="Allowed Range", ylab="MAE(",\305,")") I did use "\\oA" (without quotes) in place of \305 in the above command. Please help. Many thanks. Kanu This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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] How to find the path or the current file?
hacking up on gabor's solution, i've created a trivial function that will allow you to access a file given a path relative to the path of the file calling the function. to be concrete, suppose you have two files -- one library and one executable -- located in two sibling directories, and you want one of them to access (e.g., source) the other without the need to specify the absolute path, and irrespectively of the current working directory. here is a simple example. mkdir foo/{bin,lib} -p echo ' # the library file foo = function() cat("foo\n") ' > foo/lib/lib.r echo ' # the executable file source("http://miscell.googlecode.com/svn/rpath/rpath.r";) source(rpath("../lib/lib.r")) foo() ' > foo/bin/bin.r now you can execute foo/bin/bin.r from whatever location, or source it in r within whatever working directory, and still have it load foo/lib/lib.r: r foo/bin/bin.r # foo (cd foo; r bin/bin.r) # foo r -e 'source("foo/bin/bin.r")' # foo (cd foo/bin; r -e 'source("bin.r")') # foo so the trick for you is to source rpath, and voila. (note, it's not foolproof; as duncan explained, such approach may not work in some circumstances.) does this address your problem? hilsen, vQ Gabor Grothendieck wrote: > See: > > https://stat.ethz.ch/pipermail/r-help/2009-January/184745.html > > On Tue, Mar 24, 2009 at 7:16 AM, Marie Sivertsen > wrote: > >> Dear useRs, >> >> I have a collection of source file and some of these call others. The files >> are distribute among a number of directories, and to know how to call some >> other file they need to know what file is currently executed. >> >> As example, I have a file 'search.R' located in directory 'bin' which needs >> to access the file 'terms.conf' located in the directory 'conf', a sibling >> of 'bin'. I can have somethings like readLines('../conf/terms.conf') in >> search.R, but this work only if search.R is executed from bin, when getwd is >> 'bin'. But when search.R calls from the parent as bin/search.R or any other >> derectory then R complains that it could not find the file >> '../conf/terms.conf'. >> >> So my questions is: how can the file search.R, when executied, discover its >> own location and load terms.conf from > search.R>/../conf/terms.conf? the location of search.R can be unrelated to >> the current directory. >> >> Mvh. >> Marie __ 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] Merging rows in dataframes
I've added an example to FAQ 3 on the home page that illustrates group_concat. http://sqldf.googlecode.com On Wed, Mar 25, 2009 at 9:06 AM, Gabor Grothendieck wrote: > In the Links box to the right on the sqldf home page click on > "SQLite - aggregate functions" and lookup group_concat. > > On Wed, Mar 25, 2009 at 9:05 AM, Schragi Schwartz > wrote: >> Thank you, your answer was extremely helpful. One last problem though: one >> of the aggregate functions I'd like to apply on the columns is >> concatentation (equivalent to the paste() function). So if I have a given >> character column in three separate rows sharing the same ids with the value >> "apple" in the first, "banana" in the second, and "orange" in the third, in >> the summarizing row I'd like to receive output in the form >> "apple|banana|orange". Is there any way to do this? >> >> Thanks again, >> Schragi >> >> -Original Message- >> From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] >> Sent: Tuesday, March 24, 2009 12:50 AM >> To: Schraga Schwartz >> Cc: r-help@r-project.org >> Subject: Re: [R] Merging rows in dataframes >> >> Using sqldf you only need two statements, infile <- file(...) and >> DF <- sqldf("select min(a), max(b), mean(c), ... from infile group by id"). >> The file statement identifies the filename and the second reads it >> into sqlite (without >> going through R), summarizes it and then reads the summarized version >> into R. You may also need to provide info on its format if its not in the >> default format. See example 4a on home page and the other examples >> there: >> http://sqldf.googlecode.com >> >> >> On Mon, Mar 23, 2009 at 5:58 PM, Schraga Schwartz >> wrote: >>> Hello, >>> >>> I have a dataframe with 40 columns and around 450,000 rows. The first >> column >>> in each row is a factor id and the remaining are numeric. Some rows have >> the >>> same ids. What I want to do is to merge each set of rows sharing the same >>> ids (id set) into one single row (summarizing row) with that id. To create >>> the summarizing row, I'd like to apply a different function on each of the >>> original columns in the id set. Some columns within the summarizing row >> will >>> equal the mean of the columns in the id set, others will equal the >> minimum, >>> others the maximum. >>> >>> To do this, I tried using the by() function. However, this was extremely >>> slow (it ran for more than two hours before I stopped it). Also, it used >> up >>> all of 16 GB of memory on my machine. Is there any more efficient >> function, >>> both in terms of time and memory, to do this sort of thing? >>> >>> Thank you very much, >>> Schraga 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@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 find the path or the current file?
Wacek Kusnierczyk wrote: > hacking up on gabor's solution, i've created a trivial function that > will allow you to access a file given a path relative to the path of the > file calling the function. > > to be concrete, suppose you have two files -- one library and one > executable -- located in two sibling directories, and you want one of > them to access (e.g., source) the other without the need to specify the > absolute path, and irrespectively of the current working directory. > here is a simple example. > > mkdir foo/{bin,lib} -p > > echo ' ># the library file >foo = function() cat("foo\n") > ' > foo/lib/lib.r > > echo ' ># the executable file >source("http://miscell.googlecode.com/svn/rpath/rpath.r";) >source(rpath("../lib/lib.r")) >foo() > ' > foo/bin/bin.r > one thing i forgot to add: that contrarily to what gabor warned about his solution, you don't have to have the call to rpath at the top level, and can embed it in nested nevironments or calls; thus, the following executable: echo ' # the executable file source("http://miscell.googlecode.com/svn/rpath/rpath.r";) (function() (function() (function() { source(rpath("../lib/lib.r")) foo() })())())() ' > foo/bin/bin.r will still work as below. > now you can execute foo/bin/bin.r from whatever location, or source it > in r within whatever working directory, and still have it load > foo/lib/lib.r: > > r foo/bin/bin.r > # foo > > (cd foo; r bin/bin.r) > # foo > > r -e 'source("foo/bin/bin.r")' > # foo > > (cd foo/bin; r -e 'source("bin.r")') > # foo > > so the trick for you is to source rpath, and voila. (note, it's not > foolproof; as duncan explained, such approach may not work in some > circumstances.) > > does this address your problem? > > hilsen, > vQ > > Gabor Grothendieck wrote: > >> See: >> >> https://stat.ethz.ch/pipermail/r-help/2009-January/184745.html >> >> On Tue, Mar 24, 2009 at 7:16 AM, Marie Sivertsen >> wrote: >> >> >>> Dear useRs, >>> >>> I have a collection of source file and some of these call others. The files >>> are distribute among a number of directories, and to know how to call some >>> other file they need to know what file is currently executed. >>> >>> As example, I have a file 'search.R' located in directory 'bin' which needs >>> to access the file 'terms.conf' located in the directory 'conf', a sibling >>> of 'bin'. I can have somethings like readLines('../conf/terms.conf') in >>> search.R, but this work only if search.R is executed from bin, when getwd is >>> 'bin'. But when search.R calls from the parent as bin/search.R or any other >>> derectory then R complains that it could not find the file >>> '../conf/terms.conf'. >>> >>> So my questions is: how can the file search.R, when executied, discover its >>> own location and load terms.conf from >> search.R>/../conf/terms.conf? the location of search.R can be unrelated to >>> the current directory. >>> >>> Mvh. >>> Marie __ 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] Requesting help with lattice again
Hello, this is a request for assistance that I submitted earlier, this time with the dataset. My mistake for taking up bandwidth. I've also rephrased the question to address an additional concern. I'm working on a windows XP machine with R 2.8.1 1). I'd like a barchart (or other lattice type display) HSI ~ of the three factors (Region, Scenario and HydroState). However barchart complains > library(reshape) > library(lattice) > barchart(Wbirdsm$HSI ~ WBirdsm$Scenario | WBridsm$Region) > # This works, but only marginally. I'd like specify the interaction between the variables ( Scenario and HydroState) >What is the best way to combine these factors so they can be treated as a single variable and rewrite the barchart call? > barchart(Wbirdsm$HSI ~ WBirdsm$"interaction between Scenario and HydroState") ~ Wbirdsm$Region) The second question refers back to my original posting. 2) # using dotplot instead of barchart I use the following code. > key.variable <- list(space = "right", text = list(levels(wbirdm$variable)), points = list(pch = 1:3, col=c("red","green", "blue"))) > dotplot(wbirdm$value ~ wbirdm$variable | wbirdm$Region, col=c(1:9), pch= rep(c(1:3), key = key.variable, groups=wbirdm$variable, ylab= "Mean HSI")) > # However the key legend doesn't appear in the plot with this sequence and the labels are too along the panels. Is there a way to address this? thank you very much for the assistance. Steve This is part of the larger data base, after I passed it thru melt. Region Species Scenario HydroState HSI 1Eastern Panhandle WBLong NSMAve 0.165945170 2Eastern Panhandle WBLong NSMDry 0.056244263 3Eastern Panhandle WBLong NSMWet 0.290692607 4Eastern Panhandle WBLong ECBAve 0.165945170 5Eastern Panhandle WBLong ECB Dry 0.056244263 6Eastern Panhandle WBLong ECB Wet 0.290692607 7Eastern Panhandle WBLong CERPAve 0.165945170 8Eastern Panhandle WBLong CERPDry 0.056244263 9Eastern Panhandle WBLong CERPWet 0.290692607 10 Long Pine Key / South Taylor Slough WBLong NSMAve 0.151159734 11 Long Pine Key / South Taylor Slough WBLong NSMDry 0.067348863 12 Long Pine Key / South Taylor Slough WBLong NSMWet 0.20738 13 Long Pine Key / South Taylor Slough WBLong ECBAve 0.151159734 14 Long Pine Key / South Taylor Slough WBLong ECB Dry 0.067348863 15 Long Pine Key / South Taylor Slough WBLong ECB Wet 0.20738 16 Long Pine Key / South Taylor Slough WBLong CERPAve 0.151159734 17 Long Pine Key / South Taylor Slough WBLong CERPDry 0.067348863 18 Long Pine Key / South Taylor Slough WBLong CERPWet 0.20738 19 Northern Taylor Slough WBLong NSMAve 0.115503291 20 Northern Taylor Slough WBLong NSMDry 0.005617136 21 Northern Taylor Slough WBLong NSMWet 0.252428530 22 Northern Taylor Slough WBLong ECBAve 0.115503291 23 Northern Taylor Slough WBLong ECB Dry 0.005617136 24 Northern Taylor Slough WBLong ECB Wet 0.252428530 25 Northern Taylor Slough WBLong CERPAve 0.115503291 26 Northern Taylor Slough WBLong CERPDry 0.005617136 27 Northern Taylor Slough WBLong CERPWet 0.252428530 28 East Slough WBLong NSMAve 0.313215457 29 East Slough WBLong NSMDry 0.046917053 30 East Slough WBLong NSMWet 0.447002596 31 East Slough WBLong ECBAve 0.313215457 32 East Slough WBLong ECB Dry 0.046917053 33 East Slough WBLong ECB Wet 0.447002596 34 East Slough WBLong CERPAve 0.313215457 35 East Slough WBLong CERPDry 0.046917053 36 East Slough WBLong CERPWet 0.046917053 37Shark Slough WBLong NSMAve 0.479722873 38Shark Slough WBLong NSMDry 0.232024256 39Shark Slough WBLong NSMWet 0.449336931 40Shark Slough WBLong ECBAve 0.479722873 41Shark Slough WBLong ECB Dry 0.232024256 42Shark Slough WBLong ECB Wet 0.449336931 43Shark Slough WBLong CERPAve 0.4797
Re: [R] Doing %o% that operates on columns instead of atomics
Maybe something like the code below? There is surely a more elegant way of handling the indices, maybe with plyr? -s > xx <- array(1:6,c(3,2)); xx [,1] [,2] [1,]14 [2,]25 [3,]36 > yy <- array(1:12,c(3,4)); yy [,1] [,2] [,3] [,4] [1,]147 10 [2,]258 11 [3,]369 12 > array( sapply(1:ncol(xx), function(i) sapply(1:ncol(yy), function(j) xx[,i]*yy[,j])), c(nrow(xx),ncol(xx),ncol(yy)) ) , , 1 [,1] [,2] [1,]14 [2,]4 10 [3,]9 18 , , 2 [,1] [,2] [1,]7 10 [2,] 16 22 [3,] 27 36 , , 3 [,1] [,2] [1,]4 16 [2,] 10 25 [3,] 18 36 , , 4 [,1] [,2] [1,] 28 40 [2,] 40 55 [3,] 54 72 > xx [,1] [,2] [1,]14 [2,]25 [3,]36 > __ 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] histogram plots with many different samples
Dear R users, I would like to draw some histograms as seen in the page whose address I wrote below. I searched through the web a lot and I found a page which describes how I can do it for older versions of R. For newer versions they recommend to install the package R.basics in R.clusters but this does not exist. The address of the web page is http://www1.maths.lth.se/help/R/plot.histogram/ Unfortunately I could not find any other resource or help. Is it possible to make histograms like I wanted with R? If so, could you please give any advise on how I can do it? Thank you, Regards, evrim [[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] Density estimation: scale back for calendar time
Dear all:Request your indulgence. The econophysics gurus do this stuff all the time: all their PDFs are smooth, with neat log x axis. 1. The kernel density estimate (KDE) function returns the empirical probability density at 2^n points (min: 512). The big question is how do I scale back the x-values (say, density$x) to x-values in terms of the original dataset? 2. To give you a concrete idea, i have a dataset of 3471 obs (x=date index, y=parameter values). Now the density estimate d<-density(x) gives be 2048 x-values. When I plot the PDF, the x axis is obviously d$x, length=2048. 3. How can I scale back these 2048 values to get a sense of calendar time (original date index)? 4. Subsidiary question is: how do i bring in the remaining values (3471-2048)? Thanks very much in advance. pradeep [[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] Angstrom Symbol on Y-axis ?
Pooja Jain wrote: Hi, I have started very recently with R in order to get excellent Box and Whisker plots. I could plot my data nicely. However, I can't figure out from R-mailing list archive or google search either, how to place an Angstrom sign/symbol on the y-axis (any axis in principle), after a usual y-axis label ? I am doing something like this: boxplot(MAE.0_6,MAE.7_12,MAE.13_20,MAE.21_40,MAE.41_100,MAE. 101_200,MAE.201_300,MAE. 301_400 ,cex .lab = 0.80 ,names = c ("0 -6 ","7 -12 ","13 -20 ","21 -40","41-100","101-200","201-300","301-400"),cex.axis=0.70,col="gold", xlab="Allowed Range", ylab="MAE(",\305,")") I did use "\\oA" (without quotes) in place of \305 in the above command. \305 works for me perfectly well (I am in latin1), or in plotmath terminology, you may want to use a ring over some letter as in expression(ring(A)). Uwe Ligges Please help. Many thanks. Kanu This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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] problem with Rscript
Well I located the error and it had to do with an existing .RData file that had a print method defined for a class which is part of a package that wasn't loaded. Starting an interactive session, removing the objects of the specialized class from the top-level environment, and re-saving the environment permitted the Rscript to run correctly. I suppose similarly if the script loaded the package it would've run also. Thanks to all for the emails with suggestions. On Mar 24, 7:10 pm, "m.u.r." wrote: > Hi all, this is probably some tricky configuration file problem, but I > figure someone here might have come across this in the past: > > In short, I've been using Rscript to run my scripts, usually > successfully. But recently I've run into a strange problem, and the > only function that causes an error is "print". > > I can create a file that contains only a print command, and it causes > an error. Here is a test file, called "test.R": > > print(69) > > That's it, just the single print line in the file. Now, when I try to > execute this file using Rscript (using the same flags I've used > successfully in the past): > > Rscript --restore --no-save test.R > > I get this error: > > Error in print(69) : could not find function "loadMethod" > Execution halted > > This problem seems to be isolated to Rscript, not R, as the following > command works just fine: > > R --restore --no-save < test.R > > has anyone ever seen anything like this with Rscript? And maybe shed > some light on why "loadMethod" can't be found when starting R via > Rscript? > > Thanks, > > Murat > > __ > r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://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] histogram plots with many different samples
Dear Evrim, That is easy to do with the ggplot2 package. You only need the data in a "long" format. melt() is very usefull to convert data from a wide to a long format. library(ggplot2) n <- 100 Wide <- data.frame(X1 = rnorm(n, mean = -0.5), X2 = rnorm(n, mean = 0, sd = 2), X3 = rnorm(n, mean = 0.5)) Long <- melt(Wide) ggplot(Long, aes(x = value, fill = variable)) + geom_histogram(position = position_dodge()) #some alternatives ggplot(Long, aes(x = value, fill = variable)) + geom_histogram() ggplot(Long, aes(x = value)) + geom_histogram() + facet_wrap(~ variable) ggplot(Long, aes(x = value)) + geom_histogram() + facet_grid(variable ~ .) 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 thierry.onkel...@inbo.be 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens evrim akar Verzonden: woensdag 25 maart 2009 15:40 Aan: r-help@r-project.org Onderwerp: [R] histogram plots with many different samples Dear R users, I would like to draw some histograms as seen in the page whose address I wrote below. I searched through the web a lot and I found a page which describes how I can do it for older versions of R. For newer versions they recommend to install the package R.basics in R.clusters but this does not exist. The address of the web page is http://www1.maths.lth.se/help/R/plot.histogram/ Unfortunately I could not find any other resource or help. Is it possible to make histograms like I wanted with R? If so, could you please give any advise on how I can do it? Thank you, Regards, evrim [[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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] Doing %o% that operates on columns instead of atomics
Is this what you want: > my.foo <- function( a, b ) a - b > z <- combn(ncol(y), 2) # get all the combinations of 2 columns > result <- do.call(cbind, lapply(seq(ncol(z)), function(.cols){ + my.foo(y[,z[1,.cols]], y[, z[2, .cols]]) + })) > > > result [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] 1 -1 -2 -3 -4 -5 -6 -7 -8 -1-2-3-4-5 -6-7-1-2-3-4-5-6-1-2-3 -4-5 2 -2 -4 -6 -8 -10 -12 -14 -16 -2-4-6-8 -10 -12 -14-2-4-6-8 -10 -12-2-4-6 -8 -10 3 -3 -6 -9 -12 -15 -18 -21 -24 -3-6-9 -12 -15 -18 -21-3-6-9 -12 -15 -18-3-6-9 -12 -15 4 -4 -8 -12 -16 -20 -24 -28 -32 -4-8 -12 -16 -20 -24 -28-4-8 -12 -16 -20 -24-4-8 -12 -16 -20 5 -5 -10 -15 -20 -25 -30 -35 -40 -5 -10 -15 -20 -25 -30 -35-5 -10 -15 -20 -25 -30-5 -10 -15 -20 -25 6 -6 -12 -18 -24 -30 -36 -42 -48 -6 -12 -18 -24 -30 -36 -42-6 -12 -18 -24 -30 -36-6 -12 -18 -24 -30 7 -7 -14 -21 -28 -35 -42 -49 -56 -7 -14 -21 -28 -35 -42 -49-7 -14 -21 -28 -35 -42-7 -14 -21 -28 -35 8 -8 -16 -24 -32 -40 -48 -56 -64 -8 -16 -24 -32 -40 -48 -56-8 -16 -24 -32 -40 -48-8 -16 -24 -32 -40 9 -9 -18 -27 -36 -45 -54 -63 -72 -9 -18 -27 -36 -45 -54 -63-9 -18 -27 -36 -45 -54-9 -18 -27 -36 -45 [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] 1-1-2-3-4-1-2-3-1-2-1 2-2-4-6-8-2-4-6-2-4-2 3-3-6-9 -12-3-6-9-3-6-3 4-4-8 -12 -16-4-8 -12-4-8-4 5-5 -10 -15 -20-5 -10 -15-5 -10-5 6-6 -12 -18 -24-6 -12 -18-6 -12-6 7-7 -14 -21 -28-7 -14 -21-7 -14-7 8-8 -16 -24 -32-8 -16 -24-8 -16-8 9-9 -18 -27 -36-9 -18 -27-9 -18-9 > > y 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 2 2 4 6 8 10 12 14 16 18 3 3 6 9 12 15 18 21 24 27 4 4 8 12 16 20 24 28 32 36 5 5 10 15 20 25 30 35 40 45 6 6 12 18 24 30 36 42 48 54 7 7 14 21 28 35 42 49 56 63 8 8 16 24 32 40 48 56 64 72 9 9 18 27 36 45 54 63 72 81 > On Wed, Mar 25, 2009 at 9:03 AM, Ken-JP wrote: > > Okay, this one is hard to put into words: > >> x <- 1:9; names(x) <- x >> y <- x %o% x >> y > > 1 2 3 4 5 6 7 8 9 > 1 1 2 3 4 5 6 7 8 9 > 2 2 4 6 8 10 12 14 16 18 > 3 3 6 9 12 15 18 21 24 27 > 4 4 8 12 16 20 24 28 32 36 > 5 5 10 15 20 25 30 35 40 45 > 6 6 12 18 24 30 36 42 48 54 > 7 7 14 21 28 35 42 49 56 63 > 8 8 16 24 32 40 48 56 64 72 > 9 9 18 27 36 45 54 63 72 81 > >> my.foo( a, b ) { c <- a - b; #really more complex, but just to illustrate >> } > > - > > What I would like to do is apply my.foo() which takes two columns, a and b, > does an operation and returns another column c. The columns I want to feed > into my.foo() are all the combinations of columns in y. So I want to apply > my.foo( y[,1], y[,1] ) and then my.foo( y[,1], y[,2] ), etc... for all > combinations() of the 10 columns in y. > > I would expect the final output to be 10x10x10. Passing 10 columns by 10 > columns to my.foo() which outputs a vector of 10 numbers at a time. > > ***So in essence, what I am trying to accomplish is like outer(), but > instead of operating on atomic values, I want to operate on columns of y. > > I know I can use loops to accomplish this, but I would like to code as > R-like as possible. I am learning a great deal about "how to think in R" > from the excellent replies on this board. > > Thanks in advance for any suggestions. > > > > -- > View this message in context: > http://www.nabble.com/Doing--o--that-operates-on-columns-instead-of-atomics-tp22701363p22701363.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. > -- 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] histogram plots with many different samples
Google for R.classes bundle which will get you to the appropriate page on the author's site where you can download and install it. Installing the bundle will install a number of packages including R.basic which contains plot.histogram. On Wed, Mar 25, 2009 at 10:40 AM, evrim akar wrote: > Dear R users, > > I would like to draw some histograms as seen in the page whose address I > wrote below. I searched through the web a lot and I found a page which > describes how I can do it for older versions of R. For newer versions they > recommend to install the package R.basics in R.clusters but this does not > exist. The address of the web page is > http://www1.maths.lth.se/help/R/plot.histogram/ > > Unfortunately I could not find any other resource or help. Is it possible to > make histograms like I wanted with R? If so, could you please give any > advise on how I can do it? > > Thank you, > > Regards, > > evrim > > [[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] Discriminant analysis - stepwise procedure
Jose Antonio wrote: Dear R users, I have some environmental variables and I need to find the best combination of them in order to separate two main groups (coded 1 and 2). I have performed a discriminant analysis using the stepclass function as a method for selecting the most relevant environmental variables. The problem is that this function includes a parameter (start.vars) and my results change a lot when I change this variable...Oh my God!!! Then, one possible functionl is not the best for my data... grupo<-stepclass(GROUP~W1+W2+W3+W4+W5+W6+W7+W8+W9+W10, data=BD, method="lda", start.vars = "W1", criterion = "AS", direction = "forward") > I have performed a redundancy analysis first, then there is not highly correlated variables in the variables that I include in the stepclass function. Can anybody help me??? Not sure if you really want criterion = "AS". Anyway, if your variables are almost equally good (or bad) to improve the criterion and you have not very much data, then it might happen that the criterion works equally well for different variables and the one that is first on your list gets selected first (we do not break "ties"). And hence, after a different variable is selected at first, this influences the variables chosen in the second step. Hence it is not that surprising what you observed. Uwe Ligges Thank you very much [[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] Angstrom Symbol on Y-axis ?
Thanks Uwe. Did the following: ylab=expression(paste("Absolute Error ", (ring(A Kanu On 25 Mar 2009, at 14:57, Uwe Ligges wrote: > > > Pooja Jain wrote: >> Hi, >> I have started very recently with R in order to get excellent Box >> and Whisker plots. I could plot my data nicely. However, I can't >> figure out from R-mailing list archive or google search either, >> how to place an Angstrom sign/symbol on the y-axis (any axis in >> principle), after a usual y-axis label ? >> I am doing something like this: >> boxplot(MAE.0_6,MAE.7_12,MAE.13_20,MAE.21_40,MAE.41_100,MAE. >> 101_200,MAE.201_300,MAE. 301_400 ,cex .lab = 0.80 ,names = c ("0 -6 >> ","7 -12 ","13 -20 ","21 >> -40 >> ","41 >> -100","101-200","201-300","301-400"),cex.axis=0.70,col="gold", >> xlab="Allowed Range", ylab="MAE(",\305,")") >> I did use "\\oA" (without quotes) in place of \305 in the above >> command. > > \305 works for me perfectly well (I am in latin1), or in plotmath > terminology, you may want to use a ring over some letter as in > expression(ring(A)). > > Uwe Ligges > > > >> Please help. >> Many thanks. >> Kanu >> This message has been checked for viruses but the contents of an >> attachment >> may still contain software viruses, which could damage your >> computer system: >> you are advised to perform your own checks. Email communications >> with the >> University of Nottingham may be monitored as permitted by UK >> legislation. >> [[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. This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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] need help with ordering of plots
I want to do a series of contour plots, 4 in all. The data is coming from a data frame named "nd.frame", which has elements "xdf", "ydf", "zdf", and "pndt". I am treating "pndt" as a factor, and it has four levels. I make a call to the lattice graphics routine "contourplot" like so: contourplot(zdf~xdf*ydf|factor(pndf),data=nd.frame) >From this I get a 2x2 grid of four contour plots. So far so good. The problem - a big problem in my situation - is that the arrangement is in the order 3 | 4 -- 1 | 2 What I need is 1 | 2 -- 3 | 4 Or 1 | 3 -- 2 | 4 How do I convince R to reorder my plots? The common wisdom seems to be that I should reorder the data in the data frame via the reorder() function. My efforts at this have been fruitless, as I can't seem to understand what the output of reorder() actually is or how to use it. And none of the documentation I have read on reorder()makes any sense to me at all. Can anyone help? Also, not to get snippy, but it seems to me that a very obvious and useful flag for the contourplot() function would be some sort of order flag, which could take arguments like "reverse" or "byrow" or "bycolumn". As far as I can tell, nothing of the sort exists. Am I right about this? If so, why is this the case? A flag in a function would be a much more convenient way of changing plotting order than actually messing around with your data. 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.
Re: [R] Plots of different aspect ratios on one page, base aligned(trellis.print)
On 3/10/09, Saptarshi Guha wrote: > Hello, > I have an example of a 2 paneled plot, with two different aspect > ratios displayed on one page. > An example would help > > n=20 > x1 <- cumsum(runif(n)) > x2 <- cumsum(runif(n)) > d <- data.frame(val=c(x1,x2),id=c(1:n,1:n), nt=c(rep("A",n),rep("B",n))) > u1 <- xyplot(val~id | nt, data=d,aspect=1,layout=c(1,2)) > u2 <- xyplot(val~id|nt, data=d,aspect=0.5,layout=c(1,2)) > postscript("~/k.ps",colormodel="rgb",paper="letter",horiz=T) > print(u1,position=c(0,0,1/3,1),more=T,newpage=T) > print(u2,position=c(1/3,0,1,1),more=F,newpage=F) > dev.off() > > > The two figures are not base aligned. I would like them share the same > the baseline and same height, if necessary the paper width and height > can be adjusted > ( i tried setting the paper width and height to no avail). This worked for me: postscript("~/k.ps",colormodel="rgb",paper="special", horizontal = FALSE, height = 6, width = 10) print(u1,position=c(0,0,1/3,1),more=T,newpage=T) print(u2,position=c(1/3,0,1,1),more=F,newpage=F) dev.off() -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.
[R] constrOptim workaround for "L-BFGS-B" or Box Constraints
This is not so much a question as a contribution, but comments are welcome. Comments: 1) thank you very much to Paul Smith in the post https://stat.ethz.ch/pipermail/r-help/2008-March/157249.html This is intended to build on that example with something more complex than a 2x2 set of constraints 2) "L-BFGS-B" does not appear to work in optimConst Problem: let's say you have a function y= a + b1*x1 + b2*x2 + b3*x3 + b4*x4 and you want to minimize (where b and x are the matrices of the b's and x's) error = (a + b %*% x - y) ^ 2 subject to the constraints sum(b) = 1 0= ci # STEP 1: CREATE DATA x=matrix(rnorm(45),nrow=9)/100 y=matrix(rnorm(9),nrow=9)/100 thetas=matrix(1/5,nrow=5) # STEP 2: DEFINE ERROR FUNCTION fn=function(ws){ t(x) %*% y sum((x %*% ws-y)^2) } # STEP 3: DEFINE CONSTRAINTS a=rbind(c(0, 1, 1, 1, 1),c(0,-1,-1,-1,-1)) temp=cbind(0,rbind(diag(4),-diag(4))) adj=c(1.001,.999) a=rbind(a*adj,temp) b=c(1,-1,rep(0,4),rep(-1,4)) # STEP 3: DEFINE INITIAL STARTING POINT thetas=matrix(c(1/5,1/4,1/4,1/4,1/4),nrow=5) # STEP 3 (ALT): DEFINE INITIAL STARTING POINT #thetas=matrix(runif(5),nrow=5) #thetas[2:5]=thetas[2:5]/sum(thetas[2:5]) # ((TESTING, make sure athttps://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] Requesting help with lattice again
For the first question, add a groups argument. E.g. barchart(HSI ~ Scenario | Region, Wbirdsm, groups = HydroState) Also note that using Wbirdsm$HSI makes your call less readable, so I added the data argument. For your second question, setting the key does not set the color theme. You want to set the colors using par.setting. E.g. dotplot(HSI ~ Scenario | Region, Wbirdsm, groups = HydroState, par.settings = list(superpose.symbol = list(col = c("red", "green", "blue"))), auto.key = list(space = "right")) Then use auto.key instead of key. HTH, --sundar On Wed, Mar 25, 2009 at 7:02 AM, wrote: > > Hello, this is a request for assistance that I submitted earlier, this time > with the dataset. My mistake for taking up bandwidth. I've also rephrased > the question to address an additional concern. > > I'm working on a windows XP machine with R 2.8.1 > > 1). I'd like a barchart (or other lattice type display) HSI ~ of the three > factors (Region, Scenario and HydroState). > However barchart complains > >> library(reshape) >> library(lattice) > >> barchart(Wbirdsm$HSI ~ WBirdsm$Scenario | WBridsm$Region) > >> # This works, but only marginally. I'd like specify the interaction > between the variables ( Scenario and HydroState) >> What is the best way to combine these factors so they can be treated > as a single variable and rewrite the barchart call? > >> barchart(Wbirdsm$HSI ~ WBirdsm$"interaction between Scenario and > HydroState") ~ Wbirdsm$Region) > > > > The second question refers back to my original posting. > 2) # using dotplot instead of barchart I use the following code. > >> key.variable <- list(space = "right", text = > list(levels(wbirdm$variable)), points = list(pch = 1:3, > col=c("red","green", "blue"))) >> dotplot(wbirdm$value ~ wbirdm$variable | wbirdm$Region, col=c(1:9), pch= > rep(c(1:3), key = key.variable, groups=wbirdm$variable, ylab= "Mean > HSI")) > >> # However the key legend doesn't appear in the plot with this sequence > and the labels are too along the panels. Is there a way to address this? > > > thank you very much for the assistance. > > Steve > > > This is part of the larger data base, after I passed it thru melt. > > > > Region Species Scenario HydroState > HSI > 1 Eastern Panhandle WBLong NSM Ave > 0.165945170 > 2 Eastern Panhandle WBLong NSM Dry > 0.056244263 > 3 Eastern Panhandle WBLong NSM Wet > 0.290692607 > 4 Eastern Panhandle WBLong ECB Ave > 0.165945170 > 5 Eastern Panhandle WBLong ECB Dry > 0.056244263 > 6 Eastern Panhandle WBLong ECB Wet > 0.290692607 > 7 Eastern Panhandle WBLong CERP Ave > 0.165945170 > 8 Eastern Panhandle WBLong CERP Dry > 0.056244263 > 9 Eastern Panhandle WBLong CERP Wet > 0.290692607 > 10 Long Pine Key / South Taylor Slough WBLong NSM Ave > 0.151159734 > 11 Long Pine Key / South Taylor Slough WBLong NSM Dry > 0.067348863 > 12 Long Pine Key / South Taylor Slough WBLong NSM Wet > 0.20738 > 13 Long Pine Key / South Taylor Slough WBLong ECB Ave > 0.151159734 > 14 Long Pine Key / South Taylor Slough WBLong ECB Dry > 0.067348863 > 15 Long Pine Key / South Taylor Slough WBLong ECB Wet > 0.20738 > 16 Long Pine Key / South Taylor Slough WBLong CERP Ave > 0.151159734 > 17 Long Pine Key / South Taylor Slough WBLong CERP Dry > 0.067348863 > 18 Long Pine Key / South Taylor Slough WBLong CERP Wet > 0.20738 > 19 Northern Taylor Slough WBLong NSM Ave > 0.115503291 > 20 Northern Taylor Slough WBLong NSM Dry > 0.005617136 > 21 Northern Taylor Slough WBLong NSM Wet > 0.252428530 > 22 Northern Taylor Slough WBLong ECB Ave > 0.115503291 > 23 Northern Taylor Slough WBLong ECB Dry > 0.005617136 > 24 Northern Taylor Slough WBLong ECB Wet > 0.252428530 > 25 Northern Taylor Slough WBLong CERP Ave > 0.115503291 > 26 Northern Taylor Slough WBLong CERP Dry > 0.005617136 > 27 Northern Taylor Slough WBLong CERP Wet > 0.252428530 > 28 East Slough WBLong NSM Ave > 0.313215457 > 29 East Slough WBLong NSM Dry > 0.046917053 > 30 East Slough WBLong NSM Wet > 0.447002596 > 31 East Slough WBLong ECB Ave > 0.313215457 > 32 East Slough WBLong ECB Dry > 0.046917053 > 33
Re: [R] need help with ordering of plots
On 3/25/2009 11:15 AM, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI wrote: I want to do a series of contour plots, 4 in all. The data is coming from a data frame named "nd.frame", which has elements "xdf", "ydf", "zdf", and "pndt". I am treating "pndt" as a factor, and it has four levels. I make a call to the lattice graphics routine "contourplot" like so: contourplot(zdf~xdf*ydf|factor(pndf),data=nd.frame) From this I get a 2x2 grid of four contour plots. So far so good. The problem - a big problem in my situation - is that the arrangement is in the order 3 | 4 -- 1 | 2 What I need is 1 | 2 -- 3 | 4 Or 1 | 3 -- 2 | 4 How do I convince R to reorder my plots? The common wisdom seems to be that I should reorder the data in the data frame via the reorder() function. My efforts at this have been fruitless, as I can't seem to understand what the output of reorder() actually is or how to use it. And none of the documentation I have read on reorder()makes any sense to me at all. Can anyone help? Also, not to get snippy, but it seems to me that a very obvious and useful flag for the contourplot() function would be some sort of order flag, which could take arguments like "reverse" or "byrow" or "bycolumn". As far as I can tell, nothing of the sort exists. Am I right about this? If so, why is this the case? A flag in a function would be a much more convenient way of changing plotting order than actually messing around with your data. Trellis graphics normally plot things in the order you're seeing, but a number of people (including you, it seems!) don't like that ordering. Lattice includes the "as.table=TRUE" argument to high level functions (including contourplot) to put things in a more table-like ordering. Duncan Murdoch __ 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] histogram plots with many different samples
Personally I find those types of plots difficult to interpret. Much easier to create, view, and interpret is to simply plot the lines from density estimates. See the density function or the logspline package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of evrim akar > Sent: Wednesday, March 25, 2009 8:40 AM > To: r-help@r-project.org > Subject: [R] histogram plots with many different samples > > Dear R users, > > I would like to draw some histograms as seen in the page whose address > I > wrote below. I searched through the web a lot and I found a page which > describes how I can do it for older versions of R. For newer versions > they > recommend to install the package R.basics in R.clusters but this does > not > exist. The address of the web page is > http://www1.maths.lth.se/help/R/plot.histogram/ > > Unfortunately I could not find any other resource or help. Is it > possible to > make histograms like I wanted with R? If so, could you please give any > advise on how I can do it? > > Thank you, > > Regards, > > evrim > > [[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] need help with ordering of plots
Cable, Samuely hanscom.af.mil> > I want to do a series of contour plots, 4 in all. The data is coming > from a data frame named "nd.frame", which has elements "xdf", "ydf", > "zdf", and "pndt". I am treating "pndt" as a factor, and it has four > levels. I make a call to the lattice graphics routine "contourplot" > like so: > > The problem - a big problem in my situation - is that the arrangement is > in the order I know, it's really a bit of guesswork which parameters work for special plots. Nevertheless, if you are unsure, always look on the xyplot page and try one of the parameter there. Your friend is called as.table. If you need a really crazy ordering, reorder your factor: Dieter # library(lattice) x <- seq(pi/4, 5 * pi, length.out = 10) y <- seq(pi/4, 5 * pi, length.out = 10) r <- as.vector(sqrt(outer(x^2, y^2, "+"))) grid <- expand.grid(x=x, y=y) grid$z <- cos(r^2) * exp(-r/(pi^3)) grid$class= rep(letters[1:4],each=25) contourplot(z~x*y|class, grid, region = TRUE,as.table=TRUE) grid$rclass = factor(grid$class,levels=c("c","b","a","d")) contourplot(z~x*y|rclass, grid, region = TRUE,as.table=TRUE) __ 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] Plot inside For loop
Hi I am plotting a set of data inside a for loop. Is it possible to use plot in for loop without redrawing the whole plot? Am using par(new=TRUE) but that draws on top of the previous plot. Couldn't find any threads about the topic. Thanks Mohan -- __ 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] Manual sort in a for loop
Dear all, I am trying to manually re-sort rows in a number of tables. The rows aren't sorted on any particular values but are simply ordered by user choice (as shown by the row numbers in the code). I have been able to carry out each re-arrangement without the use of the 'for' loop, but cannot seem to successfully execute the statements when incorporated into the loop. The code I have is as follows: table_year=1951 for (i in (paste("arunoff_",year,"_temp",sep=""))) { assign(paste("arunoff_",table_year, sep=""),paste("arunoff_",table_year,"_temp")[c(10,7,9,5,4,12,1,3,2,8,11,6),]) table_year = table_year+1 } The error I get is: Error in paste("arunoff_", table_year, "_temp")[c(10, 7, 9, 5, 4, 12, : incorrect number of dimensions ...depsite this not occurring when I do each table individually (so it can't be a case of there not being enough rows, as> dim(arunoff_1951_temp) gives [1] 12 11 I have a feeling that it may be a syntax error, possibly between 'temp' and the square bracket, but I can't be sure of this. Any solutions or advice offered would be gratefully received. Many thanks, Steve _ [[elided Hotmail spam]] __ 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] wavethresh start.level problem
Dear R users, I am running R-2.8.1 with wavethresh-2.2-11 I have a problem with the function wr, used for reconstructing wd objects. The problem is that I cannot set start.level to any integer value greater than 1. Whenever I set it to any value greater than 1, I get: Building level: 1 reflect: access error (-1,3) Error in mywr(wd = sw.db2A0, start.level = 5, verbose = TRUE, return.object = TRUE) : convolveC: error exit (6) My series is 2^7 long, so I should be able to start the reconstruction from higher levels. Does any one know how to get round this problem? I need to start the reconstruction from higher levels, because I need the approximations and details series reconstructed for each level at the resolution of the highest level. For this reason I need to set the respective approximations coefficients to 0. If I start reconstruction from the lowest level, during reconstruction the coefficients are recalculated and they are no longer 0. I would be grateful also if someone suggests some alternative way of calculating the reconstructions I need, for example using different packages. I selected wavethresh to work with because it is last updated and seems well supported. Regards, Martin Ivanov __ 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] pca vs. pfa: dimension reduction
Can't make sense of calculated results and hope I'll find help here. I've collected answers from about 600 persons concerning three variables. I hypothesise those three variables to be components (or indicators) of one latent factor. In order to reduce data (vars), I had the following idea: Calculate the factor underlying these three vars. Use the loadings and the original var values to construct an new (artificial) var: (B1 * X1) + (B2 * X2) + (B3 * X3) = ArtVar (brackets for readability). Use ArtVar for further analysis of the data, that is, as predictor etc. In my (I realise, elementary) psychological statistics readings I was taught to use pca for these problems. Referring to Venables & Ripley (2002, chapter 11), I applied "princomp" to my vars. But the outcome shows 4 components -- which is obviously not what I want. Reading further I found "factanal", which produces loadings on the one specified factor very fine. But since this is a contradiction to theoretical introductions in so many texts I'm completely confused whether I'm right with these calculations. (1) Is there an easy example, which explains the differences between pca and pfa? (2) Which R procedure should I use to get what I want? Thank you for your help Sören Refs.: Venables, W. N., and Ripley, B. D. (2002). Modern applied statistics with S (4th edition). New York: Springer. __ 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] Density estimation: scale back for calendar time
I am afraid your notion of a "concrete idea" is less concrete than what I would need to understand what you are requesting. Your first lines of example code should be: library() density(x, ) ... since stats::density() by default would return 512 y estimates, even if the length of x were longer. > x <- rnorm(3471) > plot(density(x)) > str(density(x)) List of 7 $ x: num [1:512] -3.98 -3.96 -3.94 -3.93 -3.91 ... $ y: num [1:512] 7.98e-06 -- David Winsemius On Mar 25, 2009, at 9:30 AM, Pradeep Raje wrote: Dear all:Request your indulgence. The econophysics gurus do this stuff all the time: all their PDFs are smooth, with neat log x axis. 1. The kernel density estimate (KDE) function returns the empirical probability density at 2^n points (min: 512). The big question is how do I scale back the x-values (say, density$x) to x-values in terms of the original dataset? 2. To give you a concrete idea, i have a dataset of 3471 obs (x=date index, y=parameter values). Now the density estimate d<-density(x) gives be 2048 x-values. When I plot the PDF, the x axis is obviously d$x, length=2048. 3. How can I scale back these 2048 values to get a sense of calendar time (original date index)? 4. Subsidiary question is: how do i bring in the remaining values (3471-2048)? You seem to have the idea that the original data is "lined up" with the density estimates. That is not so. Thanks very much in advance. pradeep [[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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] histogram plots with many different samples
Or use frequency polygons, if you want to stay with the interpretability of a histogram. Hadley On Wed, Mar 25, 2009 at 12:07 PM, Greg Snow wrote: > Personally I find those types of plots difficult to interpret. Much easier > to create, view, and interpret is to simply plot the lines from density > estimates. See the density function or the logspline package. > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of evrim akar >> Sent: Wednesday, March 25, 2009 8:40 AM >> To: r-help@r-project.org >> Subject: [R] histogram plots with many different samples >> >> Dear R users, >> >> I would like to draw some histograms as seen in the page whose address >> I >> wrote below. I searched through the web a lot and I found a page which >> describes how I can do it for older versions of R. For newer versions >> they >> recommend to install the package R.basics in R.clusters but this does >> not >> exist. The address of the web page is >> http://www1.maths.lth.se/help/R/plot.histogram/ >> >> Unfortunately I could not find any other resource or help. Is it >> possible to >> make histograms like I wanted with R? If so, could you please give any >> advise on how I can do it? >> >> Thank you, >> >> Regards, >> >> evrim >> >> [[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. > -- 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] Plot inside For loop
It's unclear to me what your expected output is. If you are trying to add additional data sets to an existing plot then ?lines should be sufficient. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mohan Singh Sent: Wednesday, March 25, 2009 1:54 PM To: r-help@r-project.org Subject: [R] Plot inside For loop Hi I am plotting a set of data inside a for loop. Is it possible to use plot in for loop without redrawing the whole plot? Am using par(new=TRUE) but that draws on top of the previous plot. Couldn't find any threads about the topic. Thanks Mohan -- __ 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. -- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. References to "Merrill Lynch" are references to any company in the Merrill Lynch & Co., Inc. group of companies, which are wholly-owned by Bank of America Corporation. Secu! rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this E-communication may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -- __ 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] Manual sort in a for loop
Aren't you missing a sep='' in your last call to paste? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steve Murray Sent: Wednesday, March 25, 2009 1:58 PM To: r-help@r-project.org Subject: [R] Manual sort in a for loop Dear all, I am trying to manually re-sort rows in a number of tables. The rows aren't sorted on any particular values but are simply ordered by user choice (as shown by the row numbers in the code). I have been able to carry out each re-arrangement without the use of the 'for' loop, but cannot seem to successfully execute the statements when incorporated into the loop. The code I have is as follows: table_year=1951 for (i in (paste("arunoff_",year,"_temp",sep=""))) { assign(paste("arunoff_",table_year, sep=""),paste("arunoff_",table_year,"_temp")[c(10,7,9,5,4,12,1,3,2,8,11, 6),]) table_year = table_year+1 } The error I get is: Error in paste("arunoff_", table_year, "_temp")[c(10, 7, 9, 5, 4, 12, : incorrect number of dimensions ...depsite this not occurring when I do each table individually (so it can't be a case of there not being enough rows, as> dim(arunoff_1951_temp) gives [1] 12 11 I have a feeling that it may be a syntax error, possibly between 'temp' and the square bracket, but I can't be sure of this. Any solutions or advice offered would be gratefully received. Many thanks, Steve _ [[elided Hotmail spam]] __ 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. -- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. References to "Merrill Lynch" are references to any company in the Merrill Lynch & Co., Inc. group of companies, which are wholly-owned by Bank of America Corporation. Secu! rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this E-communication may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -- __ 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] pca vs. pfa: dimension reduction
On 03/25/09 19:06, soeren.vo...@eawag.ch wrote: > Can't make sense of calculated results and hope I'll find help here. > > I've collected answers from about 600 persons concerning three > variables. I hypothesise those three variables to be components (or > indicators) of one latent factor. In order to reduce data (vars), I > had the following idea: Calculate the factor underlying these three > vars. Use the loadings and the original var values to construct an new > (artificial) var: (B1 * X1) + (B2 * X2) + (B3 * X3) = ArtVar (brackets > for readability). Use ArtVar for further analysis of the data, that > is, as predictor etc. > > In my (I realise, elementary) psychological statistics readings I was > taught to use pca for these problems. Referring to Venables & Ripley > (2002, chapter 11), I applied "princomp" to my vars. But the outcome > shows 4 components -- which is obviously not what I want. Reading > further I found "factanal", which produces loadings on the one > specified factor very fine. But since this is a contradiction to > theoretical introductions in so many texts I'm completely confused > whether I'm right with these calculations. > > (1) Is there an easy example, which explains the differences between > pca and pfa? (2) Which R procedure should I use to get what I want? Possibly what you want is the first principal component, which the weighted sum that accounts for the most variance of the three variables. It does essentially what you say in your first paragraph. So you want something like p1 <- princomp(cbind(X1,X2,X3),scores=TRUE) p1$scores[,1] The trouble with factanal is that it does a rotation, and the default is varimax. The first factor will usually not be the same as the first principal component (I think). Perhaps there is another rotation option that will give you this, but why bother even to look? (I didn't, obviously.) Jon -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron __ 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] Manual sort in a for loop
I assume you need to use 'get' to retrieve the value: table_year=1951 for (i in (paste("arunoff_",year,"_temp",sep=""))) { assign(paste("arunoff_",table_year, sep=""),get(paste("arunoff_",table_year,"_temp"))[c(10,7,9,5,4,12,1,3,2,8,11,6),]) table_year = table_year+1 } On Wed, Mar 25, 2009 at 1:58 PM, Steve Murray wrote: > > Dear all, > > I am trying to manually re-sort rows in a number of tables. The rows aren't > sorted on any particular values but are simply ordered by user choice (as > shown by the row numbers in the code). I have been able to carry out each > re-arrangement without the use of the 'for' loop, but cannot seem to > successfully execute the statements when incorporated into the loop. The code > I have is as follows: > > table_year=1951 > for (i in (paste("arunoff_",year,"_temp",sep=""))) { > assign(paste("arunoff_",table_year, > sep=""),paste("arunoff_",table_year,"_temp")[c(10,7,9,5,4,12,1,3,2,8,11,6),]) > table_year = table_year+1 > } > > > The error I get is: > > Error in paste("arunoff_", table_year, "_temp")[c(10, 7, 9, 5, 4, 12, : > incorrect number of dimensions > > ...depsite this not occurring when I do each table individually (so it can't > be a case of there not being enough rows, as> dim(arunoff_1951_temp) gives > [1] 12 11 > > I have a feeling that it may be a syntax error, possibly between 'temp' and > the square bracket, but I can't be sure of this. > > > Any solutions or advice offered would be gratefully received. > > Many thanks, > > Steve > > _ > [[elided Hotmail spam]] > > __ > 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] Interpolate x from y
On Mar 25, 2009, at 8:37 AM, Greg wrote: Forgive me for not being more clear. Would you expect that one y value returns more than one x? I don't No, I don't either. I want to know the value of that x, however. For example: x <- c(2.743, 3.019, 3.329, 3.583, 4.017) y <- c(0.000, 0.025, 0.025, 0.158, 1.000) I would like to know the value of x when y is 0.1 and 0.9. If I try to "trick" approx() to give the answer I'm looking for by switching x & y (e.g., approx(y, x)) the (perfectly reasonable) warning, "In approx(y, x, c(0.1, 0.9)) : collapsing to unique 'x' values" is thrown. ?lm ?predict > x <- c(2.743, 3.019, 3.329, 3.583, 4.017) > y <- c(0.000, 0.025, 0.025, 0.158, 1.000) > predict(lm(x ~ y)) 12345 3.104855 3.129001 3.129001 3.257457 4.070686 I'm simply wondering if it's possible to interpolate to an x-axis-- similar to approx()'s behaviour to interpolate to a y-axis, but in reverse. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] diversify the values of the x-Axis...
Hii, Is it possible in R to write out to the graph the exact values of the X-Axis, even if the values are high ? I will avoid to get the values in this Form for example: 3e+06 Can anybody help ? -- View this message in context: http://www.nabble.com/diversify-the-values-of-the-x-Axis...-tp22705098p22705098.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] Manual sort in a for loop
well, the literal answer is that paste("arunoff_",table_year,"_temp") is a character vector of length 1 so your indexing cannot work. What you want is to index the data that corresponds to this variable name, ?get But I should stress that this manipulation with assign and get seems completely unnecessary (not to mention that your for loop is quite redundant --- what's "i" for?). Did you try to use list() to collect your data instead of assign()? (as i suggested to you recently) Hope this helps, baptiste On 25 Mar 2009, at 17:58, Steve Murray wrote: > > Dear all, > > I am trying to manually re-sort rows in a number of tables. The rows > aren't sorted on any particular values but are simply ordered by > user choice (as shown by the row numbers in the code). I have been > able to carry out each re-arrangement without the use of the 'for' > loop, but cannot seem to successfully execute the statements when > incorporated into the loop. The code I have is as follows: > > table_year=1951 > for (i in (paste("arunoff_",year,"_temp",sep=""))) { > assign(paste("arunoff_",table_year, > sep=""),paste("arunoff_",table_year,"_temp") > [c(10,7,9,5,4,12,1,3,2,8,11,6),]) > table_year = table_year+1 > } > > > The error I get is: > > Error in paste("arunoff_", table_year, "_temp")[c(10, 7, 9, 5, 4, > 12, : > incorrect number of dimensions > > ...depsite this not occurring when I do each table individually (so > it can't be a case of there not being enough rows, as> > dim(arunoff_1951_temp) gives [1] 12 11 > > I have a feeling that it may be a syntax error, possibly between > 'temp' and the square bracket, but I can't be sure of this. > > > Any solutions or advice offered would be gratefully received. > > Many thanks, > > Steve > > _ > [[elided Hotmail spam]] > > __ > 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. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ [[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] Plot inside For loop
Hi, Brain, I have a similar question. lines() can only add lines to plot(). If I use xyplot(), how do I add lines from a different dataset? Thanks. Jun On Wed, Mar 25, 2009 at 1:18 PM, Rowe, Brian Lee Yung (Portfolio Analytics) wrote: > It's unclear to me what your expected output is. If you are trying to > add additional data sets to an existing plot then ?lines should be > sufficient. > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Mohan Singh > Sent: Wednesday, March 25, 2009 1:54 PM > To: r-help@r-project.org > Subject: [R] Plot inside For loop > > > Hi > > I am plotting a set of data inside a for loop. > > Is it possible to use plot in for loop without redrawing the whole > plot? Am using par(new=TRUE) but that draws on top of the previous plot. > > Couldn't find any threads about the topic. > > Thanks > Mohan > -- > > __ > 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. > > -- > This message w/attachments (message) may be privileged, confidential or > proprietary, and if you are not an intended recipient, please notify the > sender, do not use or share it and delete it. Unless specifically indicated, > this message is not an offer to sell or a solicitation of any investment > products or other financial product or service, an official confirmation of > any transaction, or an official statement of Merrill Lynch. Subject to > applicable law, Merrill Lynch may monitor, review and retain > e-communications (EC) traveling through its networks/systems. The laws of > the country of each sender/recipient may impact the handling of EC, and EC > may be archived, supervised and produced in countries other than the country > in which you are located. This message cannot be guaranteed to be secure or > error-free. References to "Merrill Lynch" are references to any company in > the Merrill Lynch & Co., Inc. group of companies, which are wholly-owned by > Bank of America Corporation. Secu! > rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank > Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition > to Any Banking Service or Activity * Are Not Insured by Any Federal > Government Agency. Attachments that are part of this E-communication may > have additional important disclosures and disclaimers, which you should > read. This message is subject to terms available at the following link: > http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch > you consent to the foregoing. > -- > > __ > 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. > -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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] Creating date seq in data frame
Hi, I have the following type of data: myData <- data.frame(x = 1:5, y = letters[1:5], xDate = seq(as.Date("2001/2/1"), as.Date("2005/2/1"), by="year") ) > myData x y xDate 1 a 2001-02-01 2 b 2002-02-01 3 c 2003-02-01 4 d 2004-02-01 5 e 2005-02-01 What I need is a new column, say xDate2, that for each xDate (or for each unique combination of x,y, and xDate), I will have few days before and few days after, as follow: myData x y xDate xDate2 1 a 2001-02-01 2001-01-30 1 a 2001-02-01 2001-01-31 *1 a 2001-02-01 2001-02-01* (original row) 1 a 2001-02-01 2001-02-02 1 a 2001-02-01 2001-02-03 2 b 2002-02-01 2002-01-30 2 b 2002-02-01 2002-01-31 *2 b 2002-02-01 2002-02-01* (original row) 2 b 2002-02-01 2002-02-02 2 b 2002-02-01 2002-02-03 ... 5 e 2005-02-01 2005-01-30 5 e 2005-02-01 2005-01-31 *5 e 2005-02-01 2005-02-01 *(original row) 5 e 2005-02-01 2005-02-02 5 e 2005-02-01 2005-02-03 The actual xDate on my data is not as nicely sequenced as the above example. But the idea is the same, that I would like to get few days before and after for my each xDate. I've tried tapply, by and direct assignment like myData$xDate2 <- seq(xDate - 5, xDate + 5, by="day") and the like, but without result. Any idea is appreciated. Thanks much, Ferry [[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] Plot inside For loop
I understood this to mean you want to open a new plotting window on each iteration of the loop. If this is correct, I usually go about it by using x11() If you're looking to add additional lines or points, then you may want to look at the aptly named functions lines() and points(). If neither of these are your goal, then I'm afraid I'll need more clarification on what you're trying to do. Benjamin -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mohan Singh Sent: Wednesday, March 25, 2009 1:54 PM To: r-help@r-project.org Subject: [R] Plot inside For loop Hi I am plotting a set of data inside a for loop. Is it possible to use plot in for loop without redrawing the whole plot? Am using par(new=TRUE) but that draws on top of the previous plot. Couldn't find any threads about the topic. Thanks Mohan -- __ 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. === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S. News & World Report (2008). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}} __ 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] "[.data.frame" and lapply
Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5))) str(d) lapply(d, "[", i= c(1)) # fine, this extracts the first columns lapply(d, "[", j= c(1, 3)) # doesn't do nothing ?! library(plyr) llply(d, "[", j= c(1, 3)) # same Am i misinterpreting the meaning of "j", which I thought was an argument of the method "[.data.frame"? args(`[.data.frame`) function (x, i, j, drop = if (missing(i)) TRUE else length(cols) == 1) Many thanks, baptiste _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ 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 Graph Link strength ( I am making mistake please help)
Hello R experts, I went through R mailing,Nabble R.I could not find solution.Can someone help me. I have undirected Graph. Here is an example of spreadsheet I have( Unique 3559 Nodes) snippet of 4 rows. Node1 Node2 Weights 1 2 5 2 3 30 2 4 30 1 4 5 3 4 30 1 3 2 I created a program reading the csv and created a Adjacency matrix.From the adjacency matrix I created graph.I am not sure the mistake I am making. Program to read and create Matrix matrixmy<-scan("test.csv",sep=",",skip=1) arr=array(0,dim=c(4,4)) a<-1 while(a<=length(matrixmy)) { i=matrixmy[a] a<-a+1 j=matrixmy[a] a<-a+1 k=matrixmy[a] arr[i,j]<-k arr[j,i]<-k a<-a+1 } Created matrix mat1<-matrix(data=arr,nrow=4,ncol=4) g<-graph.adjacency(adjmatrix=mat1,mode=c("undirected")) betweenness(g) The answer I get is 0 0 0 0 I was expecting Node 1 will have high value. Can someone tell me why it is happening like this. Thanks in advance. Nathna -- View this message in context: http://www.nabble.com/Weighted-Graph-Link-strength-%28-I-am-making-mistake-please-help%29-tp22707957p22707957.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] Plot inside For loop
basically the for loop goes something like this setCounters(135); for(i in 1:query) { plot(c2data[start1:count,],c3data[start1:count,],xlim=c(-30,100), ylim=c(-30,90), sub=i); points(..); #count increments } so if i use windows() or x11(), i get different plot windows if I use par(), i get one plot, but it redraws on top of previous plots, so if my query goes from 1 to 5, it plots 5 plots on top of each other, which in some ways, is ok, but doesn't go well for putting it in a publication. i want to draw a single plot with additional data from each for loop.. as the loop proceeds, it adds another set of data onto the previous plot , i suppose, it doesn't redraw the axis and labels and just plot the data Mohan On 25 Mar 2009, at 18:43, Nutter, Benjamin wrote: > I understood this to mean you want to open a new plotting window on > each > iteration of the loop. If this is correct, I usually go about it by > using x11() > > If you're looking to add additional lines or points, then you may want > to look at the aptly named functions lines() and points(). > > If neither of these are your goal, then I'm afraid I'll need more > clarification on what you're trying to do. > > Benjamin > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org > ] > On Behalf Of Mohan Singh > Sent: Wednesday, March 25, 2009 1:54 PM > To: r-help@r-project.org > Subject: [R] Plot inside For loop > > Hi > > I am plotting a set of data inside a for loop. > > Is it possible to use plot in for loop without redrawing the whole > plot? Am using par(new=TRUE) but that draws on top of the previous > plot. > > Couldn't find any threads about the topic. > > Thanks > Mohan > -- > > __ > 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. > > > === > > P Please consider the environment before printing this e-mail > > Cleveland Clinic is ranked one of the top hospitals > in America by U.S. News & World Report (2008). > Visit us online at http://www.clevelandclinic.org for > a complete listing of our services, staff and > locations. > > > Confidentiality Note: This message is intended for use > only by the individual or entity to which it is addressed > and may contain information that is privileged, > confidential, and exempt from disclosure under applicable > law. If the reader of this message is not the intended > recipient or the employee or agent responsible for > delivering the message to the intended recipient, you are > hereby notified that any dissemination, distribution or > copying of this communication is strictly prohibited. If > you have received this communication in error, please > contact the sender immediately and destroy the material in > its entirety, whether electronic or hard copy. Thank you. > -- CASL, MLG UCD, Dublin +353-85-7279622 [[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] Plot inside For loop
This might not be particularly elegant, but if you put your initial plot() outside of the loop and then use the loop to place your points, you might get what you want. If others have better solutions, I'd be interested as well. Note that if you take this approach, you might want to specify xaxt="n" and yaxt="n" and draw your own axes. plot(NA,NA,xlim=c(-30,100), ylim=c(-30,90), ...); for(i in 1:query) { points(..); #count increments } axis(...) From: Mohan Singh [mailto:mohan.si...@ucd.ie] Sent: Wednesday, March 25, 2009 3:00 PM To: Nutter, Benjamin Cc: r-help@r-project.org Subject: Re: [R] Plot inside For loop basically the for loop goes something like this setCounters(135); for(i in 1:query) { plot(c2data[start1:count,],c3data[start1:count,],xlim=c(-30,100), ylim=c(-30,90), sub=i); points(..); #count increments } so if i use windows() or x11(), i get different plot windows if I use par(), i get one plot, but it redraws on top of previous plots, so if my query goes from 1 to 5, it plots 5 plots on top of each other, which in some ways, is ok, but doesn't go well for putting it in a publication. i want to draw a single plot with additional data from each for loop.. as the loop proceeds, it adds another set of data onto the previous plot , i suppose, it doesn't redraw the axis and labels and just plot the data Mohan On 25 Mar 2009, at 18:43, Nutter, Benjamin wrote: I understood this to mean you want to open a new plotting window on each iteration of the loop. If this is correct, I usually go about it by using x11() If you're looking to add additional lines or points, then you may want to look at the aptly named functions lines() and points(). If neither of these are your goal, then I'm afraid I'll need more clarification on what you're trying to do. Benjamin -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mohan Singh Sent: Wednesday, March 25, 2009 1:54 PM To: r-help@r-project.org Subject: [R] Plot inside For loop Hi I am plotting a set of data inside a for loop. Is it possible to use plot in for loop without redrawing the whole plot? Am using par(new=TRUE) but that draws on top of the previous plot. Couldn't find any threads about the topic. Thanks Mohan -- __ 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. === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S. News & World Report (2008). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. Thank you. -- CASL, MLG UCD, Dublin +353-85-7279622 === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S. News & World Report (2008). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. 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 cod
Re: [R] Weighted Graph Link strength ( I am making mistake please help)
Hello Nathan, a couple of points. 1) You did not write it, but it seems that you use the igraph package. It might be worth pointing this out, and also, to post to the igraph-help mailing list if you don't get any answer here. 2) igraph can easily create graphs from edge lists, there is no need to construct an adjacency matrix by hand. 3) Only the (not yet released) 0.6 version of igraph supports weighted betweenness calculation, version 0.5.1 simply ignores the weights. (And then all betweenness values are zero for your full graph.) 4) You have to call the edge attribute containing the weights 'weight' (lowercase) or explicitly supply them in the betweenness() call, otherwise they are ignored. 5. So here is how to do what you want, with igraph 0.6. Suppose you have the following in the /tmp/test.csv file: Node1,Node2,weight 1,2,5 2,3,30 2,4,30 1,4,5 3,4,30 1,3,2 Then the code is: library(igraph) mat <- read.csv("/tmp/text.csv") g <- graph.data.frame(mat, dir=FALSE) betweenness(g) and the result is 3 0 0 0 Best, Gabor On Wed, Mar 25, 2009 at 7:56 PM, Sur Nathan wrote: > > Hello R experts, > > I went through R mailing,Nabble R.I could not find solution.Can someone > help me. > > I have undirected Graph. > > Here is an example of spreadsheet I have( Unique 3559 Nodes) > > snippet of 4 rows. > > Node1 Node2 Weights > 1 2 5 > 2 3 30 > 2 4 30 > 1 4 5 > 3 4 30 > 1 3 2 > > > I created a program reading the csv and created a Adjacency matrix.From the > adjacency matrix I created graph.I am not sure the mistake I am making. > > Program to read and create Matrix > > matrixmy<-scan("test.csv",sep=",",skip=1) > > arr=array(0,dim=c(4,4)) > a<-1 > > while(a<=length(matrixmy)) > { > i=matrixmy[a] > a<-a+1 > j=matrixmy[a] > a<-a+1 > > k=matrixmy[a] > > > arr[i,j]<-k > arr[j,i]<-k > > a<-a+1 > } > > Created matrix > > mat1<-matrix(data=arr,nrow=4,ncol=4) > > g<-graph.adjacency(adjmatrix=mat1,mode=c("undirected")) > > betweenness(g) > > The answer I get is > > 0 0 0 0 > > I was expecting Node 1 will have high value. > > Can someone tell me why it is happening like this. > > Thanks in advance. > > Nathna > > > -- > View this message in context: > http://www.nabble.com/Weighted-Graph-Link-strength-%28-I-am-making-mistake-please-help%29-tp22707957p22707957.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. > -- Gabor Csardi UNIL DGM __ 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] turning of html help
Hi Simon, the help-pages for ?options don't list the properties chmhelp and htmlhelp if I remember correctly. But these are the two options you should set to FALSE if you don't want HTML-Help (nor CHM-based help on Windows). options(htmlhelp=FALSE) options(chmhelp=FALSE) Regards, Jannis __ 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 identify a symbol is defined from which package
Thanks for your reply. But for some packages, it works. For others, you may get Error: 'theName' is not an exported object from 'namespace:A' What does "exported object" mean? On Mar 25, 6:48 am, Duncan Murdoch wrote: > hong shen wrote: > > Hi list, > > > I encountered a situation that a data frame is defined by two packages. > > Both of them are loaded by library(). My questions are > > > 1. How could I tell the data frame is from which package? > > find("theName") > > will tell you where it found a variable called theName. > > > 2. If I want to reference the data frame from package A insted of B, how > > can I do it? > > A::theName > > or > > B::theName > > will find whichever one you want. > > Duncan Murdoch > > > Thanks! > > hshen > > > __ > > r-h...@r-project.org mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > __ > r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://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 identify a symbol is defined from which package
A::thename works only when thename is exported by the name space A. A:::thename works only when thename is defined in the name space A. getAnywhere(thename)$objs$"package:A" always works. On Mar 25, 6:48 am, Duncan Murdoch wrote: > hong shen wrote: > > Hi list, > > > I encountered a situation that a data frame is defined by two packages. > > Both of them are loaded by library(). My questions are > > > 1. How could I tell the data frame is from which package? > > find("theName") > > will tell you where it found a variable called theName. > > > 2. If I want to reference the data frame from package A insted of B, how > > can I do it? > > A::theName > > or > > B::theName > > will find whichever one you want. > > Duncan Murdoch > > > Thanks! > > hshen > > > __ > > r-h...@r-project.org mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > __ > r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://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] R's "validity" on MedStats
Hi Folks, Some of you (since you have contributed) are aware of a quite vigorous discussion currently in progress on the MedStats Google Group. Others, who possibly could contribute usefully, may not be. For the moment it is at the top of the "Discussions" list at http://groups.google.com/group/MedStats with the title {MEDSTATS} Re: The number of requests for R help If you click on that title, you will be taken to the posting (by Martin Holt) which initiated the discussion. Best wishes to all, Ted. E-Mail: (Ted Harding) Fax-to-email: +44 (0)870 094 0861 Date: 25-Mar-09 Time: 19:47:47 -- 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] Plot inside For loop
not really, as plot(NA,NA,xlim=c(-30,100), ylim=c(-30,90), ...); is the main plotting statement inside the loop, draws different scatterplots for each loop i can draw points or lines inside for loop, but not the plot(NA,NA,xlim=c(-30,100), ylim=c(-30,90), ...); statement, it draws on top of previous plot(..) and gives overlapping diagrams was wondering if there is any way where I can plot new data on previous plot, more like updating the plot with additional data keeping axis n labels same thanks very much Mohan On 25 Mar 2009, at 19:15, Nutter, Benjamin wrote: > This might not be particularly elegant, but if you put your initial > plot() outside of the loop and then use the loop to place your > points, you might get what you want. If others have better > solutions, Id be interested as well. Note that if you take this > approach, you might want to specify xaxt=n and yaxt=n and draw > your own axes. > > plot(NA,NA,xlim=c(-30,100), ylim=c(-30,90), ...); > for(i in 1:query) { > points(..); > > #count increments > } > axis( ) > > > From: Mohan Singh [mailto:mohan.si...@ucd.ie] > Sent: Wednesday, March 25, 2009 3:00 PM > To: Nutter, Benjamin > Cc: r-help@r-project.org > Subject: Re: [R] Plot inside For loop > > basically the for loop goes something like this > > setCounters(135); > > for(i in 1:query) { > plot(c2data[start1:count,],c3data[start1:count,],xlim=c(-30,100), > ylim=c(-30,90), sub=i); > points(..); > > #count increments > } > > so if i use windows() or x11(), i get different plot windows > > if I use par(), i get one plot, but it redraws on top of previous > plots, so if my query goes from 1 to 5, it plots 5 plots on top of > each other, which in some ways, is ok, but doesn't go well for > putting it in a publication. > > i want to draw a single plot with additional data from each for > loop.. as the loop proceeds, it adds another set of data onto the > previous plot , i suppose, it doesn't redraw the axis and labels and > just plot the data > > Mohan > > > On 25 Mar 2009, at 18:43, Nutter, Benjamin wrote: > > > I understood this to mean you want to open a new plotting window on > each > iteration of the loop. If this is correct, I usually go about it by > using x11() > > If you're looking to add additional lines or points, then you may want > to look at the aptly named functions lines() and points(). > > If neither of these are your goal, then I'm afraid I'll need more > clarification on what you're trying to do. > > Benjamin > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org > ] > On Behalf Of Mohan Singh > Sent: Wednesday, March 25, 2009 1:54 PM > To: r-help@r-project.org > Subject: [R] Plot inside For loop > > Hi > > I am plotting a set of data inside a for loop. > > Is it possible to use plot in for loop without redrawing the whole > plot? Am using par(new=TRUE) but that draws on top of the previous > plot. > > Couldn't find any threads about the topic. > > Thanks > Mohan > -- > > __ > 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. > > > === > > P Please consider the environment before printing this e-mail > > Cleveland Clinic is ranked one of the top hospitals > in America by U.S. News & World Report (2008). > Visit us online at http://www.clevelandclinic.org for > a complete listing of our services, staff and > locations. > > > Confidentiality Note: This message is intended for use > only by the individual or entity to which it is addressed > and may contain information that is privileged, > confidential, and exempt from disclosure under applicable > law. If the reader of this message is not the intended > recipient or the employee or agent responsible for > delivering the message to the intended recipient, you are > hereby notified that any dissemination, distribution or > copying of this communication is strictly prohibited. If > you have received this communication in error, please > contact the sender immediately and destroy the material in > its entirety, whether electronic or hard copy. Thank you. > > > -- > CASL, MLG > UCD, Dublin > +353-85-7279622 > > > > > > > === > P Please consider the environment before printing this e-mail > > > Cleveland Clinic is ranked one of the top hospitals > in America by U.S. News & World Report (2008). > Visit us online at http://www.clevelandclinic.org for > a complete listing of our services, staff and > locations. > > > Confidentiality Note: This message is intended for use > only by the individual or entity to which it is addressed > and may contain information that is privileged, > confidential, and exempt from disclosure under applicable >
Re: [R] pca vs. pfa: dimension reduction
Hi Sören, >> (1) Is there an easy example, which explains the differences between >> pca and pfa? (2) Which R procedure should I use to get what I want? There are a number of fundamental differences between PCA and FA (Factor Analysis), which unfortunately are quite widely ignored. FA is explicitly model-based, whereas PCA does not invoke an explicit model. FA is also designed to detect structure, whereas PCA focuses on variance, to put things simply. In more detail, the two methods "attack" the covariance matrix in different ways: in PCA the focus of decomposition is on the diagonal elements, whereas in FA the focus is on the off-diagonal elements. Take a look at Prof. Revelle's psych package (funtion omega &c). Note also that factanal has a rotation = "none" option. Regards, Mark. soeren.vogel wrote: > > Can't make sense of calculated results and hope I'll find help here. > > I've collected answers from about 600 persons concerning three > variables. I hypothesise those three variables to be components (or > indicators) of one latent factor. In order to reduce data (vars), I > had the following idea: Calculate the factor underlying these three > vars. Use the loadings and the original var values to construct an new > (artificial) var: (B1 * X1) + (B2 * X2) + (B3 * X3) = ArtVar (brackets > for readability). Use ArtVar for further analysis of the data, that > is, as predictor etc. > > In my (I realise, elementary) psychological statistics readings I was > taught to use pca for these problems. Referring to Venables & Ripley > (2002, chapter 11), I applied "princomp" to my vars. But the outcome > shows 4 components -- which is obviously not what I want. Reading > further I found "factanal", which produces loadings on the one > specified factor very fine. But since this is a contradiction to > theoretical introductions in so many texts I'm completely confused > whether I'm right with these calculations. > > (1) Is there an easy example, which explains the differences between > pca and pfa? (2) Which R procedure should I use to get what I want? > > Thank you for your help > > Sören > > > Refs.: > > Venables, W. N., and Ripley, B. D. (2002). Modern applied statistics > with S (4th edition). New York: Springer. > > __ > 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/pca-vs.-pfa%3A-dimension-reduction-tp22707926p22709481.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] Hopefully a simple question
What am I missing here? Both of my column headers in the 'FREQ' table are found in the 'genotype'; however, they aren't being recognized. > colnames(FREQ) [1] "X17362526" "X17362627" > colnames(genotype) [1] "X17362311" "X17362316" "X17362346" "X17362420" "X17362421" "X17362422" "X17362435" "X17362438" "X17362459" [10] "X17362488" "X17362493" "X17362526" "X17362542" "X17362565" "X17362566" "X17362581" "X17362594" "X17362605" [19] "X17362627" "X17362642" "X17363363" "X17363364" "X17363388" "X17363389" "X17363404" "X17363410" > colnames(genotype)==colnames(FREQ) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [19] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [[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] Hopefully a simple question
Dear Jacy, Try this: colnames(FREQ) %in% colnames(genotype) See ?"%in%" for details. Also, take a look at also ?match. HTH, Jorge On Wed, Mar 25, 2009 at 3:49 PM, Crosby, Jacy R wrote: > What am I missing here? Both of my column headers in the 'FREQ' table are > found in the 'genotype'; however, they aren't being recognized. > > > colnames(FREQ) > [1] "X17362526" "X17362627" > > > colnames(genotype) > [1] "X17362311" "X17362316" "X17362346" "X17362420" "X17362421" > "X17362422" "X17362435" "X17362438" "X17362459" > [10] "X17362488" "X17362493" "X17362526" "X17362542" "X17362565" > "X17362566" "X17362581" "X17362594" "X17362605" > [19] "X17362627" "X17362642" "X17363363" "X17363364" "X17363388" > "X17363389" "X17363404" "X17363410" > > > colnames(genotype)==colnames(FREQ) > [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > FALSE FALSE FALSE FALSE FALSE FALSE FALSE > [19] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > > > >[[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. > [[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] How to find the path or the current file?
Wacek, this work for me. Takk! Mvh. Marie On Wed, Mar 25, 2009 at 2:59 PM, Wacek Kusnierczyk < waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > Wacek Kusnierczyk wrote: > > hacking up on gabor's solution, i've created a trivial function that > > will allow you to access a file given a path relative to the path of the > > file calling the function. > > > > to be concrete, suppose you have two files -- one library and one > > executable -- located in two sibling directories, and you want one of > > them to access (e.g., source) the other without the need to specify the > > absolute path, and irrespectively of the current working directory. > > here is a simple example. > > > > mkdir foo/{bin,lib} -p > > > > echo ' > ># the library file > >foo = function() cat("foo\n") > > ' > foo/lib/lib.r > > > > echo ' > ># the executable file > >source("http://miscell.googlecode.com/svn/rpath/rpath.r";) > >source(rpath("../lib/lib.r")) > >foo() > > ' > foo/bin/bin.r > > > > one thing i forgot to add: that contrarily to what gabor warned about > his solution, you don't have to have the call to rpath at the top level, > and can embed it in nested nevironments or calls; thus, the following > executable: > >echo ' > # the executable file > source("http://miscell.googlecode.com/svn/rpath/rpath.r";) >(function() > (function() > (function() { > source(rpath("../lib/lib.r")) >foo() })())())() >' > foo/bin/bin.r > > will still work as below. > > > now you can execute foo/bin/bin.r from whatever location, or source it > > in r within whatever working directory, and still have it load > > foo/lib/lib.r: > > > > r foo/bin/bin.r > > # foo > > > > (cd foo; r bin/bin.r) > > # foo > > > > r -e 'source("foo/bin/bin.r")' > > # foo > > > > (cd foo/bin; r -e 'source("bin.r")') > > # foo > > > > so the trick for you is to source rpath, and voila. (note, it's not > > foolproof; as duncan explained, such approach may not work in some > > circumstances.) > > > > does this address your problem? > > > > hilsen, > > vQ > > > > Gabor Grothendieck wrote: > > > >> See: > >> > >> https://stat.ethz.ch/pipermail/r-help/2009-January/184745.html > >> > >> On Tue, Mar 24, 2009 at 7:16 AM, Marie Sivertsen > wrote: > >> > >> > >>> Dear useRs, > >>> > >>> I have a collection of source file and some of these call others. The > files > >>> are distribute among a number of directories, and to know how to call > some > >>> other file they need to know what file is currently executed. > >>> > >>> As example, I have a file 'search.R' located in directory 'bin' which > needs > >>> to access the file 'terms.conf' located in the directory 'conf', a > sibling > >>> of 'bin'. I can have somethings like readLines('../conf/terms.conf') > in > >>> search.R, but this work only if search.R is executed from bin, when > getwd is > >>> 'bin'. But when search.R calls from the parent as bin/search.R or any > other > >>> derectory then R complains that it could not find the file > >>> '../conf/terms.conf'. > >>> > >>> So my questions is: how can the file search.R, when executied, > discover its > >>> own location and load terms.conf from >>> search.R>/../conf/terms.conf? the location of search.R can be > unrelated to > >>> the current directory. > >>> > >>> Mvh. > >>> Marie > > [[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] Piecewise
Hi, I am a biologist (relatively new to R) analyzing data which we predict to fit a power function. I was wondering if anyone knew a way to model piecewise functions in R, where across a range of values (0-x) the data is modeled as a power function, and across another range (x-inf) it is a linear function. This would be predicted by one of our hypotheses, and we would like to find the AICs and weights for a piecewise function as described, compared with a power function across the entire range. I have looked into the polySpline function, however it appears to use only polynomials, instead of the nls models I have been using. Thanks in advance for any help you might be able to offer. Cheers, -Joe Waddell __ 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.