Re: [R] Applying function with separate dataframe (calibration file) supplying some inputs
Thanks Josh, I appreciate your comments. Merge is quite easy and I guess I should just go that route. I don't have so many data points so the speed isn't really much of an issue. I was just curious whether there was anything more elegant. Yes, the function is not clear or ideal for troubleshooting. I adapted this from an excel sheet in an effort to speed my data analysis and in the excel file the final calculation was simply a long string of calculations. I appreciate your attempt to make it clearer and to chunk it into fewer easier to read pieces. I plan to go back and do that as well. Thanks again. Nate On Wed, Oct 19, 2011 at 10:33 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Hi Nathan, I honestly do not think that anything else will be much better than merging the two datasets. If the datasets are not merged, you essentially have to apply your optode function to each vial, store the results, then combine them all together. This is innefficient. Merging the datasets may be innefficient in a way, but once it is done, your function can be applied to the entire dataset in one step. If you have big data and the merge is slow, take a look at the data.table package. I have recently (not that it was bad before, I just never really knew how much it could do) been quite impressed with it. As a whole other note, your optode function was quite difficult to read, and I highly doubt you can confidently look at the code and ensure there is not a typo, missed operator, etc. somewhere in that block of formula code. I attempted to clean it up some, though perhaps not with 100% success. ### optode2 - function(cal0, T0, cal100, T100, phase, temp) { dr - pi/180 f1 - 0.801 deltaPsiK - (-0.08) deltaKsvK - 0.000383 m - 22.9 tan0T100 - tan(((cal0 + deltaPsiK * (T100 - T0))) * dr) tan0Tm - tan((cal0 + (deltaPsiK * (temp - T0))) * dr) tan100T100 - tan(cal100 * dr) tanmTm - tan(phase * dr) A - tan100T100 / tan0T100 / m * 100^2 B - tan100T100 / tan0T100 * 100 + tan100T100 / tan0T100 / m *100 - f1 / m * 100 - 100 + f1 * 100 C - tan100T100 / tan0T100 - 1 KsvT100 - (- B + (sqrt(B^2 - 4 * A * C))) / (2 * A) KsvTm - KsvT100 + (deltaKsvK * (temp - T100)) a - tanmTm / tan0Tm / m * KsvTm^2 b - tanmTm / tan0Tm * KsvTm + tanmTm / tan0Tm / m * KsvTm - f1 / m * KsvTm - KsvTm + f1 * KsvTm c - tanmTm / tan0Tm - 1 tot - tanmTm / tan0T100 big - tot * KsvTm + tanmTm / tan0T100 / m * KsvTm - f1 / m * KsvTm - KsvTm + f1 * KsvTm saturation - (-big + (sqrt((big)^2-4 * (tanmTm / tan0T100 / m * KsvTm^2) * (tot - 1 / (2 * (tot / m * KsvTm^2)) return(saturation) } ## Read in your example data d1 - read.table(textConnection( vial cal0T0 cal100 T100 1 61 1828 18 2 60.81827.118 3 60.21828.3 18 4 59.818 27.2 18), header = TRUE, stringsAsFactors = FALSE) d2 - read.table(textConnection( vial phasetemp time 1 3117.510 1 31.5 17.420 1 32.8 17.530 2 29.0 17.5 10 2 29.7 17.5 20 2 30.9 17.5 30 3 27.1 17.4 10 3 27.6 17.4 20 3 28.1 17.5 30 4 31.0 17.6 10 4 33.3 17.6 20 4 35.617.6 30), header = TRUE, stringsAsFactors = FALSE) closeAllConnections() dat - merge(d1, d2, by = vial) ## optode wrapper f - function(d) optode2(d$cal0, d$T0, d$cal100, d$T100, d$phase, d$temp) dat$oxygen - f(dat) dat ### Cheers, Josh On Wed, Oct 19, 2011 at 8:38 PM, Nathan Miller natemille...@gmail.com wrote: Hello, I am not entirely sure the subject line captures what I am trying to do, but hopefully this description of the problem will help folks to see my challenge and hopefully offer constructive assistance. I have an experimental setup where I measure the decrease in oxygen in small vials as an organism, such as an oyster, consumes the oxygen. Each vial is calibrated before the experiment and these calibrations are used to convert the raw data after the experiment into oxygen values. I end up with two dataframes. One has the calibration data and for example could look like this vial cal0T0 cal100 T100 1 61 1828 18 2 60.81827.118 3 60.21828.3 18 4 59.818 27.2 18 The second is a data file which could look like this vial phasetemp time 1 3117.510 1 31.5 17.420 1 32.8 17.530 2 29.0 17.5 10 2 29.7 17.5 20 2 30.9 17.5 30 3 27.1 17.4 10 3 27.6 17.4 20 3 28.1 17.5 30 4
Re: [R] Levenshtein-Distance
check the help archives. hclust with method=ward might be what you are looking for On Wed, Oct 19, 2011 at 2:43 PM, Jörg Reuter jo...@reuter.at wrote: I am very new to R, so sorry that I ask stupid things. I want compare a Matrix row by row and at the end I want to a Matrix with the Levenshtein-Distance. Example: The Data (Learningpath in a E-Learning-System): 5 12 24 35 1 24 35 3 35 35 45 35 Now I need a comand, which compare the first line with the second, then with the third and write the result in a new Matrix. I found many Funktion in R, but all compare Strings, but I have numbers. After that I want to use the ward-argorithm at the result. Can anyone give me a hint, I am at the end with my nervs. Joerg __ 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] Levenshtein-Distance
My big problem is not ward, it is to calculate the Levenshtein-Distance. check the help archives. hclust with method=ward might be what you are looking for On Wed, Oct 19, 2011 at 2:43 PM, Jörg Reuter jo...@reuter.at wrote: I am very new to R, so sorry that I ask stupid things. I want compare a Matrix row by row and at the end I want to a Matrix with the Levenshtein-Distance. Example: The Data (Learningpath in a E-Learning-System): 5 12 24 35 1 24 35 3 35 35 45 35 Now I need a comand, which compare the first line with the second, then with the third and write the result in a new Matrix. I found many Funktion in R, but all compare Strings, but I have numbers. After that I want to use the ward-argorithm at the result. Can anyone give me a hint, I am at the end with my nervs. Joerg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to remove all objects except the sequence
Dear All: I would like to know if there is plausible way to say to R to remove all elements in the memory but the sequence. I have a code which makes a loop, and what I want is after the programme has performed all the operation over every ith element, to remove all the objects, expect the sequence parameter. I included the option rm(list=ls(all=TRUE)), but obviously that removes the sequence as well. I know that I can give the names of the objects to remove, but instead of doing so I would like to tell R remove all but the sequence. Is there a way for doing so? The reason for removing all the objects after each operation is saving some memory, as the operation I am doing involves some bootstrapping, after the loop reaches a certain ith element, the operations start to be really slow. So I want to faster the loop by removing the objects and free memory after every operation. Below is my code: setwd(C:\\Dokumente und Einstellung\\.) library(tsDyn) z-(1:1000)### sequence parameter sink(prueba.txt) for (i in seq(z)) { P1-read.csv(2R_EQ_P_R1.csv) P2-read.csv(2R_EQ_P_R2.csv) c-data.frame(P1[i],P2[i]) c.t-ts(c)*-1 try(print(z[i])) try(SeoTest-TVECM.SeoTest(c.t, lag=1, beta=1, trim=0.1, nboot=100)) try(summary(SeoTest)) rm(list=ls(all=TRUE)) ### Here I want to erase all but z } best, Sergio René [[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 remove all objects except the sequence
Hi Sergio, how about this: rm(list=setdiff(ls(),z)) cheers. Am 20.10.2011 11:00, schrieb Sergio René Araujo Enciso: Dear All: I would like to know if there is plausible way to say to R to remove all elements in the memory but the sequence. I have a code which makes a loop, and what I want is after the programme has performed all the operation over every ith element, to remove all the objects, expect the sequence parameter. I included the option rm(list=ls(all=TRUE)), but obviously that removes the sequence as well. I know that I can give the names of the objects to remove, but instead of doing so I would like to tell R remove all but the sequence. Is there a way for doing so? The reason for removing all the objects after each operation is saving some memory, as the operation I am doing involves some bootstrapping, after the loop reaches a certain ith element, the operations start to be really slow. So I want to faster the loop by removing the objects and free memory after every operation. Below is my code: setwd(C:\\Dokumente und Einstellung\\.) library(tsDyn) z-(1:1000)### sequence parameter sink(prueba.txt) for (i in seq(z)) { P1-read.csv(2R_EQ_P_R1.csv) P2-read.csv(2R_EQ_P_R2.csv) c-data.frame(P1[i],P2[i]) c.t-ts(c)*-1 try(print(z[i])) try(SeoTest-TVECM.SeoTest(c.t, lag=1, beta=1, trim=0.1, nboot=100)) try(summary(SeoTest)) rm(list=ls(all=TRUE)) ### Here I want to erase all but z } best, Sergio René [[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. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus __ 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 call a function defined within another function
On 19.10.2011 22:08, Sébastien Bihorel wrote: Dear R-users, I would need some advices on the proper way to call a particular function. This function is called scope.char and it is embedded in the step.gam function from the gam package. I am trying to call scope.char directly in a script but I did not find the proper way to do so. Is this even possible? If so, what is the proper syntax? You cannot, since it is only defined in the environment of the function step.gam while that is active. The gam license is GPL-2, so go ahead. Best, Uwe Ligges Thank you for your time and help. Sebastien [[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] Vegan: Anova.CCA accessing original data using option by=
Steve Pawson Steve.Pawson at scionresearch.com writes: My apologies for the delay in responding to your request for further information I have been travelling for work since you replied and have only just returned to email contact. The output from the traceback is as follows # This is the capscale model that I called beetlecap -capscale(log(beetles+1) ~ size + Clearfell + Absolute.Distance+ Distance_from_edge+ clearfell.harvest_area + Canopy.Cover + X500mnative + Litter3 + X500mexotic + X5000exotic + Condition(AdjLong + AdjLat + AdjLat.2 + AdjLat.2.long + AdjLong.3), environ, distance = bray) This is the ANOVA by margin option with the error anova(beetlecap, by=margin) Error in dimnames(x) - dn : length of 'dimnames' [2] not equal to array extent Corresponding traceback traceback() 9: `colnames-`(`*tmp*`, value = c(CAP1, CAP0)) 8: capscale(formula = log(beetles + 1) ~ size + Clearfell + Absolute.Distance + Distance_from_edge + clearfell.harvest_area + Canopy.Cover + X500mnative + Litter3 + X500mexotic + X5000exotic + Condition(AdjLong + AdjLat + AdjLat.2 + AdjLat.2.long + AdjLong.3) + Condition(size + Clearfell + Absolute.Distance + Distance_from_edge + clearfell.harvest_area + Canopy.Cover + Litter3 + X500mexotic + X5000exotic + AdjLong + AdjLat + AdjLat.2 + AdjLat.2.long + AdjLong.3), data = environ, distance = bray) [...clip...] Dear Steve Pawson, With the help of this message I was able to construct an example that gives the same error message -- this does not prove that the cause of the problem is the same, but it is possible. It may be that your *huge* model has redundant variables that cannot be analysed in marginal test: the other variables explain all, and the marginal effect of some variables is zero. With that a high number of variables as you have, this is very likely. It seems that capscale() cannot cope with this case. I fixed capscale in http://vegan.r-forge.r-project.org and now it handles smoothly these redundant variables (skips them in permutation test, and reports df=0). From your point of view it may be unfortunate that I released a new version of vegan a couple of hours before checking R-News mail, and therefore this fix is not yet in the next release, and as we just had a release we probably (hopefully) will not have a new revision very soon. So your choices are either to use the vegan version in R-Forge (which must be at least r1958) or simplify your model so that you don't have redundant variables. One way of achieving this is to use command alias(beetlecap, names = TRUE) which will list the names of the variables that cannot be analysed. You can remove these variables without influencing your fitted model, because they really are redundant variables. 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.
[R] Are they fully identical: WinBUGS and OpenBUGS; R2WinBUGS and R2OpenBUGS
Hello ALL! I am running Linux, Fedora 15 64-bits, and R on it. I need to use WinBUGS and R2WinBUGS, but as far as I read, WinBUGS is closed project, to be continued with/as OpenBUGS. Thus, I have found R2OpenBUGS on OpenBUGS Contributed Code (http://openbugs.info/w/UserContributedCode), not on CRAN. Author(s) states that it is equivalent for R2WinBUGS. I tried briefly, and realized few minor differences. However, it seems to work. I wonder if anyone checked thoroughly equivalence of WinBUGS and OpenBUGS, and R2WinBUGS and R2OpenBUGS. Please, share your experience with us! All the best, PM [[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] Cairo creates italized plots?
Am 19.10.2011 17:33, schrieb Fong Chun Chan: Hi, Has anyone else run into this weird behaviour where the text in the plots created using Cairo are always italicized. For example, library(Cairo) Cairo(file='cairo_created', type='pdf', dpi=100) plot(1:10) dev.off() This produces the following attached 'cairo_created.pdf' graph. Notice how the text is italicized. The same code but using pdf() as the graphics device: pdf(file='pdf_created.pdf') plot(1:10) dev.off() Produces the attached 'pdf_created.pdf' graph in which the text is non-italicized. I am unable to find out what the difference is here and set the Cairo() function to produce non-italicized text in my graphs. Both graphic devices appear to default to Helvetica. Anyone have any suggestions? Here on Win 7 and R 2.13.0 and Cairo 1.5-0 it was not possible to reproduce it, the plot produced on my computer with your code came with plain text, not italicized... Which plattform are you on? Did you try CairoFonts? regards, Albin -- | Albin Blaschka, Mag.rer.nat. | Etrichstrasse 26, A-5020 Salzburg | * www.albinblaschka.info * www.thinkanimal.info * | - It's hard to live in the mountains, hard but not hopeless! __ 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] quantmod package
i am new to the quantmod package . so if the answer is trivial please excuse me. i want to study stock values within a day. i get current stock updates using getQuotes and then want to produce usual quantmod graphs with that values. also the graph should be able of adding technical indicators. please help. in addition it will be helpful if anyone suggests how to run that code continuously to get constantly updated charts. thanks in advance for any suggestion. -- View this message in context: http://r.789695.n4.nabble.com/quantmod-package-tp3921071p3921071.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] How to change font family in a levelplot using Lattice
Dear R users: I want to assign a global font family to a levelplot such as par(family=serif) in traditional plotting. However, I can only change part of the text using panel.text(x,y,A,fontfamily=serif) or scales=list(fontfamily=serif) to change the axis number font family. How can I change the font family of xlab and ylab and the numbers shown on the legend of the levelplot? Thanks in advance, Bingzhang __ 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] Levenshtein-Distance
On Oct 20, 2011; 10:07am Jörg Reuter wrote: I want compare a Matrix row by row and at the end I want to a Matrix with the Levenshtein-Distance. Jörg, To begin with, try the following at the command prompt: ## RSiteSearch(Levenshtein) Shows, amongst other hits, that package vwr has a function to calculate Levenshtein distances. Regards, Mark. - Mark Difford (Ph.D.) Research Associate Botany Department Nelson Mandela Metropolitan University Port Elizabeth, South Africa -- View this message in context: http://r.789695.n4.nabble.com/Levenshtein-Distance-tp3920951p3921252.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] rose.diag in CircStats package
Dear R community, I tried to post a query about the use of the rose.diag function from the CircStats package to the r-help forum a few days ago. It gave all appearances of having been successful. It would have been my first post; I am correctly recieving all the R-help emails, but but the message has not appeared anywhere on the forum. Am I held up by the moderator somewhere? any help would be appreciated, thanks, Richard [[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 affybatch objects from matrix (data from qPCR array)
Hi! Is There a way to manually create an affybatch object from qPCR array data? -- View this message in context: http://r.789695.n4.nabble.com/Creating-affybatch-objects-from-matrix-data-from-qPCR-array-tp3921559p3921559.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] Levenshtein-Distance
Yes, I see many package. But the Problem is, the Package compare strings. But there is a diffrent between the caracter 1 and 2 and the number 12. All package I see compare every letter, but a number have many digits but the digits make only sense if the function see them together. I tough to change the number in caracter like 1-a but I have to much numbers. Am 20.10.2011 13:32 schrieb Mark Difford mark_diff...@yahoo.co.uk: On Oct 20, 2011; 10:07am Jörg Reuter wrote: I want compare a Matrix row by row and at the end I want to a Matrix with the Levenshtein-Distance. Jörg, To begin with, try the following at the command prompt: ## RSiteSearch(Levenshtein) Shows, amongst other hits, that package vwr has a function to calculate Levenshtein distances. Regards, Mark. - Mark Difford (Ph.D.) Research Associate Botany Department Nelson Mandela Metropolitan University Port Elizabeth, South Africa -- View this message in context: http://r.789695.n4.nabble.com/Levenshtein-Distance-tp3920951p3921252.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. [[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] Creating affybatch objects from matrix (data from qPCR array)
On 10/20/2011 04:14 AM, ali_protocol wrote: Hi! Is There a way to manually create an affybatch object from qPCR array data? Hi -- affybatch is for Affy probe information only; perhaps you mean an ExpressionSet and the Bioconductor mailing list http://bioconductor.org/packages/2.8/bioc/vignettes/Biobase/inst/doc/ExpressionSetIntroduction.pdf http://bioconductor.org/help/mailing-list/ Martin -- View this message in context: http://r.789695.n4.nabble.com/Creating-affybatch-objects-from-matrix-data-from-qPCR-array-tp3921559p3921559.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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ 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] defining independent predictors in haplo.stats
Hi all, I am doing analyses with haplo.stats in R. I know that when doing analysis with haplo.glm, I have to define my outcome variable, i.e. if it is binomial or gaussian. When looking at interactions , eg. gender * geno or life events * geno do I have to specify whether the independent factor (eg. life events) is ordinal or binomial, ? Or does the program already know because it is a GLM anyway? Haplo.stats manual does not give any information about this. As you read the manual you assume it is not necessary to define the form of the independent variables. Does any one know? thanks, Niki -- View this message in context: http://r.789695.n4.nabble.com/defining-independent-predictors-in-haplo-stats-tp3921697p3921697.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] locating minimum value in matrix
Hi, I was looking for a solution to the same problem. I just found something and thought it might be useful to share. Suppose you look for the positions of the minimum value in matrix D. Using a little euclide division solves the problem easily. Here is my code. min(D) Dv=as.vector(D) pos=which.min(Dv) j0=floor(pos/nrow(D))+1 i0=pos%%nrow(D) D[i0,j0] # must equal min(D) Hope this is useful. I. -- View this message in context: http://r.789695.n4.nabble.com/locating-minimum-value-in-matrix-tp850619p3921598.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] How to remove multiple outliers
Hi All, I am working on the dataset in which some of the variables have more than one observations with outliers . I am using below mentioned sample script library(outliers) x1 - c(10, 10, 11, 12, 13, 14, 14, 10, 11, 13, 12, 13, 10, 19, 18, 17, 10099, 10099, 10098) outlier_tf1 = outlier(x1,logical=TRUE) find_outlier1 = which(outlier_tf1==TRUE, arr.ind=TRUE) beh_input_ro1 = x1[-find_outlier1] It removes the outliers which are extrme and not all. In this example it removes only 10099, 10099 and not 10098. Thanks for the help in advance. -Ajit -- View this message in context: http://r.789695.n4.nabble.com/How-to-remove-multiple-outliers-tp3921689p3921689.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] Structural equation modelling in R compared with Amos
Can anyone give me links to reviews/comparisons of R with Amos for SEM? I have found some but they are a little old (2009). Ravi -- View this message in context: http://r.789695.n4.nabble.com/Structural-equation-modelling-in-R-compared-with-Amos-tp3921654p3921654.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 call a function defined within another function
Thanks Uwe for reply. The license is actually a problem: my package is distributed with a LGPL3 license, which is incompatible with GPL-2. I'll try to find a work-around. Sebastien 2011/10/20 Uwe Ligges lig...@statistik.tu-dortmund.de On 19.10.2011 22:08, Sébastien Bihorel wrote: Dear R-users, I would need some advices on the proper way to call a particular function. This function is called scope.char and it is embedded in the step.gam function from the gam package. I am trying to call scope.char directly in a script but I did not find the proper way to do so. Is this even possible? If so, what is the proper syntax? You cannot, since it is only defined in the environment of the function step.gam while that is active. The gam license is GPL-2, so go ahead. Best, Uwe Ligges Thank you for your time and help. Sebastien [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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 call a function defined within another function
On Wed, Oct 19, 2011 at 4:08 PM, Sébastien Bihorel pomc...@free.fr wrote: Dear R-users, I would need some advices on the proper way to call a particular function. This function is called scope.char and it is embedded in the step.gam function from the gam package. I am trying to call scope.char directly in a script but I did not find the proper way to do so. Is this even possible? If so, what is the proper syntax? Thank you for your time and help. As has already pointed out it can't really be done but if you want a hack then this will do it. It does depend on the specific position of scope.char within step.gam, library(gam) eval(body(step.gam)[[2]]) # check that its now there scope.char function (formula) { formula = update(formula, ~-1 + .) tt - terms(formula) tl - attr(tt, term.labels) if (attr(tt, intercept)) c(1, tl) else tl } -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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 remove all objects except the sequence
Thanks a lot for the answer, it works and really improves the speed of the loop. Best, Sergio René El , Eik Vettorazzi e.vettora...@uke.de escribió: Hi Sergio, how about this: rm(list=setdiff(ls(),z)) cheers. Am 20.10.2011 11:00, schrieb Sergio René Araujo Enciso: Dear All: I would like to know if there is plausible way to say to R to remove all elements in the memory but the sequence. I have a code which makes a loop, and what I want is after the programme has performed all the operation over every ith element, to remove all the objects, expect the sequence parameter. I included the option rm(list=ls(all=TRUE)), but obviously that removes the sequence as well. I know that I can give the names of the objects to remove, but instead of doing so I would like to tell R remove all but the sequence. Is there a way for doing so? The reason for removing all the objects after each operation is saving some memory, as the operation I am doing involves some bootstrapping, after the loop reaches a certain ith element, the operations start to be really slow. So I want to faster the loop by removing the objects and free memory after every operation. Below is my code: setwd(C:\\Dokumente und Einstellung\\.) library(tsDyn) z sink(prueba.txt) for (i in seq(z)) { P1 P2 c ct try(print(z[i])) try(SeoTest try(summary(SeoTest)) rm(list=ls(all=TRUE)) ### Here I want to erase all but z } best, Sergio René [[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. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus [[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] Structural equation modelling in R compared with Amos
Hi Ravi, Look at openmx, it uses R to do matrix optimization especially for SEM (though more general too). It does not have the draw paths interactively feature, but it is extremely powerful and flexible. I have used Amos, EQS, Mplus, Lisrel, and OpenMx and I believe OpenMx is competitive against any of those if you know what you are doing. I have found Amos to be particularly limited in its ability to handle complex models. If you are looking for a simpler interface to SEM in R for some basic models, he k out the SEM package by John Fox. HTH, Josh On Oct 20, 2011, at 4:56, Ravi Kulkarni ravi.k...@gmail.com wrote: Can anyone give me links to reviews/comparisons of R with Amos for SEM? I have found some but they are a little old (2009). Ravi -- View this message in context: http://r.789695.n4.nabble.com/Structural-equation-modelling-in-R-compared-with-Amos-tp3921654p3921654.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help on read.spss
I see, I struggle too with SPSS. But I use this company for help: http://www.ivoryresearch.com/custom-statistical-services-spss.php they are really helpful -- View this message in context: http://r.789695.n4.nabble.com/need-help-on-read-spss-tp3893430p3921825.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] Constructing the transition pair using loop function and paste()
Hi all, I'd like to thank those who helped me with my previous loop function question with agents/events. I have solved the problem with the advice from this community. I have now moved on to the next step, which requires me to find all the transition pair within an event. A sample data and the R commands I've written are as follow: x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transition - vector('list', length(unique(mydata$agents)))# create a list to hold the outputs transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '')} # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i} transition The actions are ordered, so what I need to do is just to paste each action to the next one to form a pair. My attempt only produced the desired result for the last agent: [[1]] NULL [[2]] NULL [[3]] NULL [[4]] NULL [[5]] NULL [[6]] NULL [[7]] NULL [[8]] NULL [[9]] NULL [[10]] NULL [[11]] [1] AE ED DC Is there any way to avoid using 2-level loop function, although to me it's the most intuitive method? Any pointer would be greatly appreciated! Regards, Sally [[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] Levenshtein-Distance
Have you considered simply changing your numbers into strings with as.character()? E.g., library(vwr) levenshtein.distance(aba,cda) num1 - 121; num2 - 341 levenshtein.distance(as.character(num1),as.character(num2)) I find that last line a little verbose to type, so I'd write a little helper which adds some generality as well. LD - function(s1, s2){ require(vwr) s1 = as.character(s1) s2 = as.character(s2) t(sapply(s1, levenshtein.distance, s2)) } Note that you can put vectors of numbers directly into LD(). Hope this helps, Michael On Thu, Oct 20, 2011 at 7:53 AM, Jörg Reuter jo...@reuter.at wrote: Yes, I see many package. But the Problem is, the Package compare strings. But there is a diffrent between the caracter 1 and 2 and the number 12. All package I see compare every letter, but a number have many digits but the digits make only sense if the function see them together. I tough to change the number in caracter like 1-a but I have to much numbers. Am 20.10.2011 13:32 schrieb Mark Difford mark_diff...@yahoo.co.uk: On Oct 20, 2011; 10:07am Jörg Reuter wrote: I want compare a Matrix row by row and at the end I want to a Matrix with the Levenshtein-Distance. Jörg, To begin with, try the following at the command prompt: ## RSiteSearch(Levenshtein) Shows, amongst other hits, that package vwr has a function to calculate Levenshtein distances. Regards, Mark. - Mark Difford (Ph.D.) Research Associate Botany Department Nelson Mandela Metropolitan University Port Elizabeth, South Africa -- View this message in context: http://r.789695.n4.nabble.com/Levenshtein-Distance-tp3920951p3921252.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. [[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] Constructing the transition pair using loop function and paste()
try this: You were redfining 'transition' within the loop x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata transition - vector('list', length(unique(mydata$agents)))# create a list to hold the outputs for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '') } # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i } transition On Thu, Oct 20, 2011 at 8:52 AM, Sally Zhen salil...@gmail.com wrote: Hi all, I'd like to thank those who helped me with my previous loop function question with agents/events. I have solved the problem with the advice from this community. I have now moved on to the next step, which requires me to find all the transition pair within an event. A sample data and the R commands I've written are as follow: x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transition - vector('list', length(unique(mydata$agents))) # create a list to hold the outputs transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '')} # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i} transition The actions are ordered, so what I need to do is just to paste each action to the next one to form a pair. My attempt only produced the desired result for the last agent: [[1]] NULL [[2]] NULL [[3]] NULL [[4]] NULL [[5]] NULL [[6]] NULL [[7]] NULL [[8]] NULL [[9]] NULL [[10]] NULL [[11]] [1] AE ED DC Is there any way to avoid using 2-level loop function, although to me it's the most intuitive method? Any pointer would be greatly appreciated! Regards, Sally [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru 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] Constructing the transition pair using loop function and paste()
Here is another way of getting the lists newtrans - lapply(split(mydata, mydata$agents), function(.agent){ + .all - paste(.agent$actions, collapse = '') + .indx - embed(seq(nchar(.all)), 2) + substring(.all, .indx[, 2], .indx[, 1]) + }) newtrans $`2857` [1] LB $`293` [1] AD DF FH HN NA AC CH $`4596` [1] FG GN NH HH HK $`498` [1] FD DF FF FH HK $`5629` [1] HH HH HR $`6018` [1] SF FX XG GT $`6178` [1] XC CV $`6209` [1] FH HJ JU $`6847` [1] GD DD DB BN NK KO OV VS SS $`7535` [1] AE ED DC $`8562` [1] KT TH HS SR RG GS SR RR RG GD DB BG On Thu, Oct 20, 2011 at 10:08 AM, Sally Zhen salil...@gmail.com wrote: I got it! Thank you so much Jim! On 20 October 2011 15:06, jim holtman jholt...@gmail.com wrote: try this: You were redfining 'transition' within the loop x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata transition - vector('list', length(unique(mydata$agents))) # create a list to hold the outputs for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '') } # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i } transition On Thu, Oct 20, 2011 at 8:52 AM, Sally Zhen salil...@gmail.com wrote: Hi all, I'd like to thank those who helped me with my previous loop function question with agents/events. I have solved the problem with the advice from this community. I have now moved on to the next step, which requires me to find all the transition pair within an event. A sample data and the R commands I've written are as follow: x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transition - vector('list', length(unique(mydata$agents))) # create a list to hold the outputs transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '')} # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i} transition The actions are ordered, so what I need to do is just to paste each action to the next one to form a pair. My attempt only produced the desired result for the last agent: [[1]] NULL [[2]] NULL [[3]] NULL [[4]] NULL [[5]] NULL [[6]] NULL [[7]] NULL [[8]] NULL [[9]] NULL [[10]] NULL [[11]] [1] AE ED DC Is there any way to avoid using 2-level loop function, although to me it's the most intuitive method? Any pointer would be greatly appreciated! Regards, Sally [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? -- Jim Holtman Data Munger Guru 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] How to call a function defined within another function
Thanks for the hack Gabor! That works just fine... (I guess until the step.gam function is re-structured :D) On Thu, Oct 20, 2011 at 9:20 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Oct 19, 2011 at 4:08 PM, Sébastien Bihorel pomc...@free.fr wrote: Dear R-users, I would need some advices on the proper way to call a particular function. This function is called scope.char and it is embedded in the step.gam function from the gam package. I am trying to call scope.char directly in a script but I did not find the proper way to do so. Is this even possible? If so, what is the proper syntax? Thank you for your time and help. As has already pointed out it can't really be done but if you want a hack then this will do it. It does depend on the specific position of scope.char within step.gam, library(gam) eval(body(step.gam)[[2]]) # check that its now there scope.char function (formula) { formula = update(formula, ~-1 + .) tt - terms(formula) tl - attr(tt, term.labels) if (attr(tt, intercept)) c(1, tl) else tl } -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com [[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 remove multiple outliers
Did you read the documentation for ?outlier. It clearly states that it removes the single (possibly repeated) value with the largest distance from the mean. That's only 10099 hereyou could perhaps apply the function more than once or write your own outlier removal script using whatever criterion you want to define outliers, but the function is doing exactly what it claims to do. On another note, why complicate things? Just use the rm.outlier() function of the same package rather than doing it (inefficiently) how you are currently. Note that outlier() returns a logical vector which can be used for direct subsetting; that there's no need to test booleans ==TRUE (since that's an identity transform on the set of booleans), and that the arr.ind = TRUE call isn't needed here. None of those make much of a difference for this problem, but they are points of good practice. Michael On Thu, Oct 20, 2011 at 8:11 AM, aajit75 aaji...@yahoo.co.in wrote: Hi All, I am working on the dataset in which some of the variables have more than one observations with outliers . I am using below mentioned sample script library(outliers) x1 - c(10, 10, 11, 12, 13, 14, 14, 10, 11, 13, 12, 13, 10, 19, 18, 17, 10099, 10099, 10098) outlier_tf1 = outlier(x1,logical=TRUE) find_outlier1 = which(outlier_tf1==TRUE, arr.ind=TRUE) beh_input_ro1 = x1[-find_outlier1] It removes the outliers which are extrme and not all. In this example it removes only 10099, 10099 and not 10098. Thanks for the help in advance. -Ajit -- View this message in context: http://r.789695.n4.nabble.com/How-to-remove-multiple-outliers-tp3921689p3921689.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Levenshtein-Distance
On Oct 20, 2011, at 7:53 AM, Jörg Reuter wrote: Yes, I see many package. But the Problem is, the Package compare strings. But there is a diffrent between the caracter 1 and 2 and the number 12. All package I see compare every letter, but a number have many digits but the digits make only sense if the function see them together. I tough to change the number in caracter like 1-a but I have to much numbers. I get the sense you and your respondents are talking paste each other, and that you do _not_ want to compare the digits in your numbers. If you have a vector that you want to change into a character, you can convert easily with indexing. This would give you a domain of 48 characters: ooops, you are one of those Nabble users who expects us to search for your prior postings tooo bad. I have decided not to track down omitted context in such instance: c(letters,LETTERS)[ c(12, 35, 24, 35)] [1] l I x I # then use the distance function There are numToASCII functions but I cannot remember them without searching. -- David. Am 20.10.2011 13:32 schrieb Mark Difford mark_diff...@yahoo.co.uk: On Oct 20, 2011; 10:07am Jörg Reuter wrote: I want compare a Matrix row by row and at the end I want to a Matrix with the Levenshtein-Distance. Jörg, To begin with, try the following at the command prompt: ## RSiteSearch(Levenshtein) Shows, amongst other hits, that package vwr has a function to calculate Levenshtein distances. Regards, Mark. - Mark Difford (Ph.D.) Research Associate Botany Department Nelson Mandela Metropolitan University Port Elizabeth, South Africa -- View this message in context: http://r.789695.n4.nabble.com/Levenshtein-Distance-tp3920951p3921252.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. [[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 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] effect function in the effects package
Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: ValueStd. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333-2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ 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] Constructing the transition pair using loop function and paste()
I got it! Thank you so much Jim! On 20 October 2011 15:06, jim holtman jholt...@gmail.com wrote: try this: You were redfining 'transition' within the loop x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata transition - vector('list', length(unique(mydata$agents)))# create a list to hold the outputs for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '') } # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i } transition On Thu, Oct 20, 2011 at 8:52 AM, Sally Zhen salil...@gmail.com wrote: Hi all, I'd like to thank those who helped me with my previous loop function question with agents/events. I have solved the problem with the advice from this community. I have now moved on to the next step, which requires me to find all the transition pair within an event. A sample data and the R commands I've written are as follow: x - c('A','D','F','H','N','A','C','H','F','D','F','F','H','K','G','D','D','B','N','K','O','V','S','S','F','H','J','U','K','T','H','S','R','G','S','R','R','G','D','B','G','F','G','N','H','H','K','L','B','X','C','V','S','F','X','G','T','H','H','H','R','A','E','D','C') y - c(rep(0293,8), rep(0498,6), rep(6847,10), rep(6209,4), rep(8562,13), rep(4596,6), rep(2857,2), rep(6178,3), rep(6018,5), rep(5629,4), rep(7535,4)) mydata - as.data.frame(cbind(x,y)) names(mydata) - c('actions', 'agents') mydata for (i in 1:length(unique(mydata$agents))){ # decompose the data frame by agents agent.i - mydata[mydata$agents == (unique(mydata$agents))[i], ] transition - vector('list', length(unique(mydata$agents)))# create a list to hold the outputs transit.i - c() for (j in 1:length(agent.i$actions)-1){ transit.i[j] - paste(agent.i$actions[j], agent.i$actions[j+1], sep = '')} # for each subset of each agent, perform the 'pairing' transition[[i]] - transit.i} transition The actions are ordered, so what I need to do is just to paste each action to the next one to form a pair. My attempt only produced the desired result for the last agent: [[1]] NULL [[2]] NULL [[3]] NULL [[4]] NULL [[5]] NULL [[6]] NULL [[7]] NULL [[8]] NULL [[9]] NULL [[10]] NULL [[11]] [1] AE ED DC Is there any way to avoid using 2-level loop function, although to me it's the most intuitive method? Any pointer would be greatly appreciated! Regards, Sally [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? [[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] help with glmmADMB ZI; function maximizer failed
bbolker wrote: emmarosenfeld emmarosenfeld at hotmail.co.uk writes: Dear all, I am having some problems trying to run a GLMM model with zero-inflation using the alpha version of glmmADMB (0.6.4) using R (2.13.1) in Windows and I would greatly appreciate some help. My count response variable (number of birds: count) fits a negative binomial distribution and the explanatory variables are both continuous and categorical (species= 17). The three random effects are site (68 of them), season (1 or 2) and land class (1 to 6). You mean species is a factor with 17 levels? I am trying to analyse the count data of 17 different species in the same model as it's a community based analysis. What are the results of str(srp12) ? Results= 'data.frame': 2312 obs. of 12 variables: $ site : Factor w/ 68 levels site1,site10,..: 1 12 23 33 54 65 67 68 2 3 ... $ season : Factor w/ 2 levels season1,season2: 1 1 1 1 1 1 1 1 1 1 ... $ count: int 23 9 6 14 12 6 10 4 9 7 ... $ species : Factor w/ 17 levels B,BF,BT,..: 1 1 1 1 1 1 1 1 1 1 ... $ site.1 : Factor w/ 68 levels site1,site10,..: 1 12 23 33 54 65 67 68 2 3 ... $ built: num 0.274 0.297 0.326 0.27 0.337 ... $ atrees : num 0.0482 0.0498 0.0443 0.0822 0.0523 ... $ btrees : num 0.81 0.847 0.884 0.88 0.851 ... $ Ctrees : num 16.8 17 19.9 10.7 16.3 ... $ landclass: Factor w/ 6 levels land1,land2,..: 3 3 3 3 3 3 3 3 3 3 ... $ distance : Factor w/ 1 level dist0500: 1 1 1 1 1 1 1 1 1 1 ... $ distcont : int 500 500 500 500 500 500 500 500 500 500 ... You are going to have a lot of difficulty fitting a random effect to a factor with two levels (see http://glmm.wikidot.com/faq for discussion). Try it as a fixed effect instead. Are you referring to season as a factor with two levels? I'll try it as fixed instead. Ideally I would also like to build in a variance structure to allow a different spread per land class. I don't know of a way to do this in glmmADMB. **Maybe** doable in MCMCglmm but I wouldn't count on it. This is the model I'm trying to run: (fm-glmmadmb(count~species*btrees+species*built+species*btrees*built+ (1|season)+(1|landclass)+(1|site), data=srp12, famil=nbinom, zeroInflation=TRUE)) Are you aware that species*btrees*built expands to include all main effects, two- and three-way interactions, i.e. the species*btrees and species*built terms are redundant. I hadn't realised that species*btrees*built allows for both two- and three- way interactions, no, i thought I had to specify those. Thanks for that. I have read most of the supporting documents to glmmADMB and studied the examples but am still struggling to make headway. This is the error message I get; Memory allocation error -- Perhaps you are trying to allocate too much memory in your program Warning: running command 'C:\Windows\system32\cmd.exe /c C:/R-2.13.1/library/glmmADMB/bin/windows32/glmmadmb.exe -maxfn 500' had status 1 Warning in shell(cmd, invisible = TRUE) : 'C:/R-2.13.1/library/glmmADMB/bin/windows32/glmmadmb.exe -maxfn 500' execution failed with error code 1 Error in glmmadmb(count ~ species * btrees + species * built + species * : The function maximizer failed I have also run: summary(fm) Which results in: Error in summary(fm) : object 'fm' not found Well, that's not surprising since the command failed. This has happened however the equation is labelled. Perhaps there is a more appropriate package that I should be using (MCMCglmm)? I am quite new to R, so it is quite possible that I am missing something, so any help would be most appreciated. __ R-help@ 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://r.789695.n4.nabble.com/help-with-glmmADMB-ZI-function-maximizer-failed-tp3918994p3922092.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] Structural equation modelling in R compared with Amos
Dear Ravi, I would also suggest you to have a look at 'lavaan' (www.lavaan.org). It has an extremely straightforward yet flexible model syntax and very good documentation. Although its statistical capabilities are not comparable to those of Mplus (which is the most powerful SEM-software I think), it is getting more and more closer to it. Personally I prefer lavaan over OpenMX, but it is also a matter of taste. HTH, Denes Hi Ravi, Look at openmx, it uses R to do matrix optimization especially for SEM (though more general too). It does not have the draw paths interactively feature, but it is extremely powerful and flexible. I have used Amos, EQS, Mplus, Lisrel, and OpenMx and I believe OpenMx is competitive against any of those if you know what you are doing. I have found Amos to be particularly limited in its ability to handle complex models. If you are looking for a simpler interface to SEM in R for some basic models, he k out the SEM package by John Fox. HTH, Josh On Oct 20, 2011, at 4:56, Ravi Kulkarni ravi.k...@gmail.com wrote: Can anyone give me links to reviews/comparisons of R with Amos for SEM? I have found some but they are a little old (2009). Ravi -- View this message in context: http://r.789695.n4.nabble.com/Structural-equation-modelling-in-R-compared-with-Amos-tp3921654p3921654.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] rose.diag in CircStats package
On Oct 20, 2011, at 6:35 AM, richard hewitt wrote: Dear R community, I tried to post a query about the use of the rose.diag function from the CircStats package to the r-help forum a few days ago. It gave all appearances of having been successful. It would have been my first post; I am correctly recieving all the R-help emails, but but the message has not appeared anywhere on the forum. Am I held up by the moderator somewhere? any help would be appreciated, thanks, It's not in the moderation queue. And I didn't see it in a search of my mailbox. The ultimate authority is the Archive at. https://stat.ethz.ch/pipermail/r-help/ -- David. Richard [[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 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] Strange R behavior for product of two sum of integers
On Oct 20, 2011, at 1:45 AM, Lei Jiang wrote: When using power operator ^, both the base and index are coerced to type real. The range of real is larger than integer. However, an ordinary multiplication operator * offers it to two integers (as always). So, to avoid the warning, just add as.real(...) to one or both multipliers (once one multiplier is real, the other must be coerced to real in the operation): sum(1000:1205)*as.real(sum(1000:1205)) [1] 51581223225 That does seem to be an infelicity that ought to be fixed. Using the infix addition operator does that same sort of coercions, so why would one expect the infix multiplication operator to refuse to do it? (sum(1000:1205))*(sum(1000:1204) +1205) [1] 51581223225 (sum(1000:1205))*(sum(1000:1204) +0) [1] 51307549650 -- David. HTH, Lei On Wed, Oct 19, 2011 at 7:44 PM, Lafaye de Micheaux Pierre laf...@dms.umontreal.ca wrote: Dear gentlemen, Can you explain me why the following happens (any OS I think, and even on 64 bits)? sum(1000:1205)^2 [1] 51581223225 sum(1000:1205)*sum(1000:1205) [1] NA Warning message: In sum(1000:1205) * sum(1000:1205) : NAs produced by integer overflow Best, Pierre -- Pierre Lafaye de Micheaux Adresse courrier: Département de Mathématiques et Statistique Université de Montréal CP 6128, succ. Centre-ville Montréal, Québec H3C 3J7 CANADA Adresse physique: Département de Mathématiques et Statistique Bureau 4249, Pavillon André-Aisenstadt 2920, chemin de la Tour Montréal, Québec H3T 1J4 CANADA Tél.: (00-1) 514-343-6607 / Fax: (00-1) 514-343-5700 laf...@dms.umontreal.ca http://www.biostatisticien.eu __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Lei Jiang Center for Computation and Technology/ Department of Computer Science Louisiana State University E-mail: lji...@cct.lsu.edu [[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 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] need help on read.spss
Try the memisc package which seems to have an independent implementation from PSPP (at least looks that way when compiling on linux) plus the ability to select variables before reading in the entire dataset. Paul Bivand - Paul Bivand Head of Analysis and Statistics Inclusion 3rd floor, 89 Albert Embankment, London SE1 7TP On 20 October 2011 14:06, Georgie georgie.por...@yahoo.co.uk wrote: I see, I struggle too with SPSS. But I use this company for help: http://www.ivoryresearch.com/custom-statistical-services-spss.php they are really helpful -- View this message in context: http://r.789695.n4.nabble.com/need-help-on-read-spss-tp3893430p3921825.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strange R behavior for product of two sum of integers
On Thu, Oct 20, 2011 at 7:50 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 20, 2011, at 1:45 AM, Lei Jiang wrote: When using power operator ^, both the base and index are coerced to type real. The range of real is larger than integer. However, an ordinary multiplication operator * offers it to two integers (as always). So, to avoid the warning, just add as.real(...) to one or both multipliers (once one multiplier is real, the other must be coerced to real in the operation): sum(1000:1205)*as.real(sum(1000:1205)) [1] 51581223225 That does seem to be an infelicity that ought to be fixed. Using the infix addition operator does that same sort of coercions, so why would one expect the infix multiplication operator to refuse to do it? This turns out not to be the case: x-2147483647L y-2147483647L x+y [1] NA Warning message: In x + y : NAs produced by integer overflow -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ 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] Strange R behavior for product of two sum of integers
On Oct 20, 2011, at 16:50 , David Winsemius wrote: That does seem to be an infelicity that ought to be fixed. Using the infix addition operator does that same sort of coercions, so why would one expect the infix multiplication operator to refuse to do it? (sum(1000:1205))*(sum(1000:1204) +1205) [1] 51581223225 The addition operator doesn't either: (sum(1000:1205))*(sum(1000:1204) +1205L) [1] NA Warning message: In (sum(1000:1205)) * (sum(1000:1204) + 1205L) : NAs produced by integer overflow Beware that 1:1 is integer but 1 is not. -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] effect function in the effects package
Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: ValueStd. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333-2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ 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] Structural equation modelling in R compared with Amos
Lavaan is a nice package too, thanks for mentioning it. Given sufficient understanding of matrices, I think OpenMx is arguably as or more powerful than Mplus---it runs circles around Mplus in terms of flexibility, although Mplus does what it does well, with (IMO) fairly sensible defaults, and simpler syntax. On Oct 20, 2011, at 7:40, Dénes TÓTH tde...@cogpsyphy.hu wrote: Dear Ravi, I would also suggest you to have a look at 'lavaan' (www.lavaan.org). It has an extremely straightforward yet flexible model syntax and very good documentation. Although its statistical capabilities are not comparable to those of Mplus (which is the most powerful SEM-software I think), it is getting more and more closer to it. Personally I prefer lavaan over OpenMX, but it is also a matter of taste. HTH, Denes Hi Ravi, Look at openmx, it uses R to do matrix optimization especially for SEM (though more general too). It does not have the draw paths interactively feature, but it is extremely powerful and flexible. I have used Amos, EQS, Mplus, Lisrel, and OpenMx and I believe OpenMx is competitive against any of those if you know what you are doing. I have found Amos to be particularly limited in its ability to handle complex models. If you are looking for a simpler interface to SEM in R for some basic models, he k out the SEM package by John Fox. HTH, Josh On Oct 20, 2011, at 4:56, Ravi Kulkarni ravi.k...@gmail.com wrote: Can anyone give me links to reviews/comparisons of R with Amos for SEM? I have found some but they are a little old (2009). Ravi -- View this message in context: http://r.789695.n4.nabble.com/Structural-equation-modelling-in-R-compared-with-Amos-tp3921654p3921654.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] bar plot issues
Hi! I have 2 problems in drawing a stacked bar plot: (1) This is a stacked bar plot with more than 100 bars next to each other. So there should not be names at the bottom of the bars because the bars are too narrow.I tried arg.names=NULL but that does not work because R uses the row names from the data.frame. How can I suppress the placing of names below the bars? (2) The position of the legend is problematic. The legend is big, more than 20 items. It overlays the bars themselves and makes the plot unreadable. I would like to move it outside the plot and have tried legend(topleft) but R complains about missing information. Here is what I have so far barplot(t(file.codes), + beside = FALSE, + col = rainbow(ncol(file.codes)), names.arg=NULL, + legend = FALSE, + main = Presidential documents - Codes per document, + xlab = document, ylab = number of codings) ### Any ideas? Thanks, Henri-Paul -- Curriculum Instruction Texas AM University TutorFind Learning Centre Email: hindiog...@gmail.com Skype: hindiogine Website: http://people.cehd.tamu.edu/~sindiogine __ 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] bar plot issues
On 20.10.2011 18:03, Henri-Paul Indiogine wrote: Hi! I have 2 problems in drawing a stacked bar plot: (1) This is a stacked bar plot with more than 100 bars next to each other. So there should not be names at the bottom of the bars because the bars are too narrow.I tried arg.names=NULL but that does not work because R uses the row names from the data.frame. How can I suppress the placing of names below the bars? It is the argument *names.arg* and it has to be set to NA. (2) The position of the legend is problematic. The legend is big, more than 20 items. It overlays the bars themselves and makes the plot unreadable. I would like to move it outside the plot and have tried legend(topleft) but R complains about missing information. arrange it outside by, e.g. increasing the size of margins (see argument mar in ?par) and place a separate legend (see ?legend) into the margins (see xps argument in ?par). Here is what I have so far barplot(t(file.codes), + beside = FALSE, + col = rainbow(ncol(file.codes)), names.arg=NULL, + legend = FALSE, + main = Presidential documents - Codes per document, + xlab = document, ylab = number of codings) ### Not reproducible since we do not have file.codes. Uwe Ligges Any ideas? Thanks, Henri-Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] heritability estimation
Moohbear, I may be able to help, in that I've had some graduate course work in plant breeding and some experience with R. However, I can't tell for certain with the information provided. What papers that use SAS or SPSS are you citing? The question I would ask, in order to determine if I could help, might be more domain-specific - what kind of traits are you measuring, what type of experiments - so I don't know if that would should be continued on this list. Peter Claussen Gylling Data Management. On Oct 14, 2011, at 8:49 AM, Moohbear wrote: Hello, I'm looking for a method to estimate narrow sense heritability of traits in a RIL population. Papers I've checked either use either SAS or SPSS or do not give any details at all. I've found some reference to using variance components in ANOVA, using the kinship or wgaim packages, but I don't have a clue as to how to do any of this. Is there any way fro a very R illiterate user to do it? Thanks -- View this message in context: http://r.789695.n4.nabble.com/heritability-estimation-tp3904908p3904908.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix Approx
Need help with finding out approx over each row of a matrix. Here is the setup: years - matrix(c(1,2,3,1,2,3),nrow=2, ncol=3,byrow=TRUE) rates - matrix(c(1,2,3,11,12,13), nrow = 2, ncol=3, byrow=TRUE) points - matrix(c(1.5, 1.5), nrow=2, ncol=1, byrow=TRUE) so basically i have above three vectors years is the X vector, rates is the Y vector and points is the points at which each row of X, Y has to be interpolated. I have tried every possible combination of approx apply but i am unable to figure out. Any help will be greatly appreciated. -- Ramneek __ 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] StatET Sweave cannot compile pdf files
I am new to R, Sweave, and LaTeX. I am running StatET with Eclipse 3.7 on a Windows 7 x64 OS. StatET also includes the Sweave add-on, which I use to try and compile a PDF document. I also installed MiKTeX 2.9, because, previously, R could not execute texi2dvi (presumably, because there was no TeX runner). Basically, no .tex file could be compiled into PDF file. After I installed MiKTeX, I was successful at compiling a .pdf file from .tex file. However, the moment I introduce pdf() function into the .Rnw file, I get a fatal error. When trying to compile this simple .Rnw file: === % \documentclass[a4paper]{article} \usepackage[OT1]{fontenc} \usepackage{Sweave} \begin{document} \title{pdftest.Rnw} \author{Egor} \maketitle echo=F, results=hide= pdf(file='figure1.pdf') plot(1:10,1:10) dev.off() @ \end{document} === I get the following error message: === Sweave(file = C:/Users/Egor/Desktop/R/Head-tracking/pdftest.Rnw) Writing to file pdftest.tex Processing code chunks with options ... 1 : term hide You can now run (pdf)latex on 'pdftest.tex' require(tools) texi2dvi(file = C:/Users/Egor/Desktop/R/Head-tracking/Data/pdftest.tex, pdf = TRUE) Error: running 'texi2dvi' on 'C:/Users/Egor/Desktop/R/Head-tracking/Data/pdftest.tex' failed LaTeX errors: C:/Users/Egor/Desktop/R/Head-tracking/Data/pdftest.tex:13: == Fatal error occ urred, no output PDF file produced! In addition: Warning message: running command 'C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texi2dvi.exe --quiet --pdf C:/Users/Egor/Desktop/R/Head-tracking/Data/pdftest.tex -I C:/Program Files/R/R-2.13.1/share/texmf/tex/latex -I C:/Program Files/R/R-2.13.1/share/texmf/bibtex/bst' had status 1 === Tell me if you need any more details. Thanks in advance for your help! --Egor [[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] Strange R behavior for product of two sum of integers
On Thu, Oct 20, 2011 at 10:37 AM, peter dalgaard pda...@gmail.com wrote: On Oct 20, 2011, at 16:50 , David Winsemius wrote: That does seem to be an infelicity that ought to be fixed. Using the infix addition operator does that same sort of coercions, so why would one expect the infix multiplication operator to refuse to do it? (sum(1000:1205))*(sum(1000:1204) +1205) [1] 51581223225 The addition operator doesn't either: (sum(1000:1205))*(sum(1000:1204) +1205L) [1] NA Warning message: In (sum(1000:1205)) * (sum(1000:1204) + 1205L) : NAs produced by integer overflow Beware that 1:1 is integer but 1 is not. Exactly. In order to prevent calculations from overflow, as.real(...) may be used for manual coercion (sometimes the machine is not that intelligent to do automatic coercing) or users can check the type of constants/variables as follows: typeof(1) [1] double typeof(sum(1:100)) [1] integer -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- Lei Jiang Center for Computation and Technology/ Department of Computer Science Louisiana State University E-mail: lji...@cct.lsu.edu [[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] bar plot issues
Hi Uwe! Thanks for the feedback. However, now the graph does not draw the y-axis nor labels and gives the following error message: Error in barplot.default(t(file.codes), beside = FALSE, names.arg = NA, : incorrect number of names This is the R code now: barplot(t(file.codes), beside = FALSE, names.arg=NA, legend = FALSE, main=test stacked bar plot, xlab=documents, ylab=number of codes, col=rainbow(ncol(file.codes))) I have head(file.codes) at the bottom of this email. Thanks, HP 2011/10/20 Uwe Ligges lig...@statistik.tu-dortmund.de: It is the argument *names.arg* and it has to be set to NA. head(file.codes) Achievement Diversity Economy EducEquity Gap HumanBenefit DCPD-200900575.scrb 2 2 4 5 21 DCPD-200900595.scrb 2 0 12 0 21 DCPD-200900884.scrb 1 0 12 0 11 DCPD-20136.scrb 2 0 1 0 10 DCPD-201000130.scrb 1 0 1 0 20 DCPD-201000636.scrb 4 0 10 3 21 InternatComp MathSciEng Poverty Standards TechnoSociety DCPD-200900575.scrb1 1 2 2 4 DCPD-200900595.scrb1 2 0 7 7 DCPD-200900884.scrb4 2 0 9 7 DCPD-20136.scrb5 1 0 2 2 DCPD-201000130.scrb1 1 0 1 2 DCPD-201000636.scrb2 2 0 8 1 WorkCareer DropOut Accountability AssessStudent Funding DCPD-200900575.scrb 7 0 0 0 0 DCPD-200900595.scrb 9 2 0 0 0 DCPD-200900884.scrb 12 0 1 2 0 DCPD-20136.scrb 5 0 0 0 1 DCPD-201000130.scrb 2 0 0 0 1 DCPD-201000636.scrb 12 0 2 1 0 Globalization AllStudents NationInterest ProfDev DCPD-200900575.scrb 0 0 0 0 DCPD-200900595.scrb 0 0 0 0 DCPD-200900884.scrb 0 0 0 0 DCPD-20136.scrb 0 0 0 0 DCPD-201000130.scrb 0 0 0 0 DCPD-201000636.scrb 0 0 0 0 NationDefense BestFirst AdmissionCollege DCPD-200900575.scrb 0 00 DCPD-200900595.scrb 0 00 DCPD-200900884.scrb 0 00 DCPD-20136.scrb 0 00 DCPD-201000130.scrb 0 00 DCPD-201000636.scrb 0 00 -- Henri-Paul Indiogine Curriculum Instruction Texas AM University TutorFind Learning Centre Email: hindiog...@gmail.com Skype: hindiogine Website: http://people.cehd.tamu.edu/~sindiogine __ 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] Running R with browser without installing anything
Dear all, the company I work for has Matlab installed for statistical/mathematical calculations and really not ready to go with R (even installing exe file for R). Therefore I was wondering is it possible to do analysis R using browser like IE, without installing anything? Thanks for your suggestion. [[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] bar plot issues
On 20.10.2011 18:58, Henri-Paul Indiogine wrote: Hi Uwe! Thanks for the feedback. However, now the graph does not draw the y-axis nor labels and gives the following error message: Error in barplot.default(t(file.codes), beside = FALSE, names.arg = NA, : incorrect number of names names.arg = rep(NA, nrow(file.codes)) in that case. Best, Uwe Ligges This is the R code now: barplot(t(file.codes), beside = FALSE, names.arg=NA, legend = FALSE, main=test stacked bar plot, xlab=documents, ylab=number of codes, col=rainbow(ncol(file.codes))) I have head(file.codes) at the bottom of this email. Thanks, HP 2011/10/20 Uwe Liggeslig...@statistik.tu-dortmund.de: It is the argument *names.arg* and it has to be set to NA. head(file.codes) Achievement Diversity Economy EducEquity Gap HumanBenefit DCPD-200900575.scrb 2 2 4 5 21 DCPD-200900595.scrb 2 0 12 0 21 DCPD-200900884.scrb 1 0 12 0 11 DCPD-20136.scrb 2 0 1 0 10 DCPD-201000130.scrb 1 0 1 0 20 DCPD-201000636.scrb 4 0 10 3 21 InternatComp MathSciEng Poverty Standards TechnoSociety DCPD-200900575.scrb1 1 2 2 4 DCPD-200900595.scrb1 2 0 7 7 DCPD-200900884.scrb4 2 0 9 7 DCPD-20136.scrb5 1 0 2 2 DCPD-201000130.scrb1 1 0 1 2 DCPD-201000636.scrb2 2 0 8 1 WorkCareer DropOut Accountability AssessStudent Funding DCPD-200900575.scrb 7 0 0 0 0 DCPD-200900595.scrb 9 2 0 0 0 DCPD-200900884.scrb 12 0 1 2 0 DCPD-20136.scrb 5 0 0 0 1 DCPD-201000130.scrb 2 0 0 0 1 DCPD-201000636.scrb 12 0 2 1 0 Globalization AllStudents NationInterest ProfDev DCPD-200900575.scrb 0 0 0 0 DCPD-200900595.scrb 0 0 0 0 DCPD-200900884.scrb 0 0 0 0 DCPD-20136.scrb 0 0 0 0 DCPD-201000130.scrb 0 0 0 0 DCPD-201000636.scrb 0 0 0 0 NationDefense BestFirst AdmissionCollege DCPD-200900575.scrb 0 00 DCPD-200900595.scrb 0 00 DCPD-200900884.scrb 0 00 DCPD-20136.scrb 0 00 DCPD-201000130.scrb 0 00 DCPD-201000636.scrb 0 00 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to cancel a R function in the command line?
Hi, This question seems very basic but I cannot find an answer on google. I have a R session on a linux command line. I called a function that is taking ages. I want to cancel the function but without killing the R session. What is the shortcut? Thanks, Rui [[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 cancel a R function in the command line?
Hi Rui, In the R terminal ctrl-c cancels the function, not the session. Cheers, Tsjerk On Oct 20, 2011 7:16 PM, Rui Esteves ruimax...@gmail.com wrote: Hi, This question seems very basic but I cannot find an answer on google. I have a R session on a linux command line. I called a function that is taking ages. I want to cancel the function but without killing the R session. What is the shortcut? Thanks, Rui [[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 cancel a R function in the command line?
Hi Tsjerk, In my command line it does not. Maybe it because I am using linux. That is my problem. Thank you for answering, Rui On Thu, Oct 20, 2011 at 7:18 PM, Tsjerk Wassenaar tsje...@gmail.com wrote: Hi Rui, In the R terminal ctrl-c cancels the function, not the session. Cheers, Tsjerk On Oct 20, 2011 7:16 PM, Rui Esteves ruimax...@gmail.com wrote: Hi, This question seems very basic but I cannot find an answer on google. I have a R session on a linux command line. I called a function that is taking ages. I want to cancel the function but without killing the R session. What is the shortcut? Thanks, Rui [[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 cancel a R function in the command line?
I found it. It is ctr shift c Rui On Thu, Oct 20, 2011 at 7:22 PM, Rui Esteves ruimax...@gmail.com wrote: Hi Tsjerk, In my command line it does not. Maybe it because I am using linux. That is my problem. Thank you for answering, Rui On Thu, Oct 20, 2011 at 7:18 PM, Tsjerk Wassenaar tsje...@gmail.comwrote: Hi Rui, In the R terminal ctrl-c cancels the function, not the session. Cheers, Tsjerk On Oct 20, 2011 7:16 PM, Rui Esteves ruimax...@gmail.com wrote: Hi, This question seems very basic but I cannot find an answer on google. I have a R session on a linux command line. I called a function that is taking ages. I want to cancel the function but without killing the R session. What is the shortcut? Thanks, Rui [[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] effect function in the effects package
Dear Professor Fox, Thanks a lot! That is an embarrassing error. After I cleaned up and simplified my codes, and ran the following two lines: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5 I am still having trouble. See below: summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: ValueStd. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333-2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5 Error in plot(effect(age, myologit, xlevels = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') On Thu, Oct 20, 2011 at 11:55 AM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ 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 cancel a R function in the command line?
On 20.10.2011 19:22, Rui Esteves wrote: Hi Tsjerk, In my command line it does not. Perhaps you arfe using a function that calls compiled code that does not look for user interrupts? try it on repeat{1+1} ... Uwe Ligges Maybe it because I am using linux. That is my problem. Thank you for answering, Rui On Thu, Oct 20, 2011 at 7:18 PM, Tsjerk Wassenaartsje...@gmail.com wrote: Hi Rui, In the R terminal ctrl-c cancels the function, not the session. Cheers, Tsjerk On Oct 20, 2011 7:16 PM, Rui Estevesruimax...@gmail.com wrote: Hi, This question seems very basic but I cannot find an answer on google. I have a R session on a linux command line. I called a function that is taking ages. I want to cancel the function but without killing the R session. What is the shortcut? Thanks, Rui [[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. __ 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] Group based trajectory modeling in R? Is there a way?
I have been searching the web for an answer on whether there is a package for group-based trajectory modeling in R. Something along the lines of what PROC TRAJ (http://www.andrew.cmu.edu/user/bjones/index.htm) accomplishes in SAS. Does anyone have any experience working with a package that does this? Thanks! C [[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] bar plot issues
Hi Uwe! 2011/10/20 Uwe Ligges lig...@statistik.tu-dortmund.de: names.arg = rep(NA, nrow(file.codes)) Yes, that works beautifully. Danke schoen! Henri-Paul -- Henri-Paul Indiogine Curriculum Instruction Texas AM University TutorFind Learning Centre Email: hindiog...@gmail.com Skype: hindiogine Website: http://people.cehd.tamu.edu/~sindiogine __ 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] Survival analysis
Hello, I need some results from the survival analysis of my data that I do not know whether exist in Survival Package or how to obtain if they do: 1. The Mean survival time 2. The standard error of the mean 3. Point and 95% Lower Upper Confidence Intervals estimates Any help will be greatly appreciated. Cem [[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] effect function in the effects package
Dear Professor Fox, I didn't include codes in between these two commands (polr and plot(effect()). I am still trying to work it out. Maybe it's related to how I coded some of the factor variables as I got some successful runs after I changed the coding for some factor variables. I will keep working on the codes and see if I can figure out. Again, your effects package, I have to say, is awesome! Jun On Thu, Oct 20, 2011 at 1:26 PM, Xu Jun junx...@gmail.com wrote: Dear Professor Fox, Thanks a lot! That is an embarrassing error. After I cleaned up and simplified my codes, and ran the following two lines: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5 I am still having trouble. See below: summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5 Error in plot(effect(age, myologit, xlevels = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') On Thu, Oct 20, 2011 at 11:55 AM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ 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
Re: [R] Running R with browser without installing anything
It runs fine off a flash drive. On Thu, Oct 20, 2011 at 1:29 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, the company I work for has Matlab installed for statistical/mathematical calculations and really not ready to go with R (even installing exe file for R). Therefore I was wondering is it possible to do analysis R using browser like IE, without installing anything? Thanks for your suggestion. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru 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] p-val issue for ranked two-group test
Hi- I'm wondering if anyone can help me with my code. I'm coming up dry when I try to get a p-value from the following code. If I make a histogram of my resampled distribution, I find the difference between by groups to be significant. I've ranked the data since I have outliers in one of my groups. mange= c(35, 60, 81, 158, 89, 130, 90, 38, 119, 137, 52, 30, 27, 115, 123, 31, 124, 91) healthy= c(46, 50, 30, 58, 32, 42, 42, 33, 19, 42, 30, 26, 38, 23, 16, 28, 42, 42, 33, 35, 51, 31, 39, 40 , 42, 38, 36, 39, 38) l.mange-length(mange) l.healthy-length(healthy) exptdiff - mean.mange - mean.healthy #the expected difference between between the mean of the ranked groups both.chemistry-c(mange, healthy) #concatenate two vectors into one in preparation for resampling the data both.ranks-rank(both.chemistry) #rank combined data in the case that there are outlying values in the data or the dataset is small reps=1000 z-rep(NA,reps) # z will the the simulated storage value for the resampling efforts for(i in 1:reps){ #create the loop x- sample(both.ranks, length(both.ranks),replace=FALSE) #instructions for how to resample where sample the entire combined data without replacment p.mange-mean(x[(1:l.mange)]) #create a simulate mean value for the resampled mange values p.healthy-mean(x[(l.mange+1):(l.mange+l.healthy)]) #create a simulated mean value for the resampled healthy values pdiff- p.mange-p.healthy #the simulated difference between groups z[i]- pdiff #the stored list of simulated differences } p=mean(z=exptdiff)*2 #2-tailed test multiply by two p hist(z, xlab=Resample Values, main=Distribution for Two-Group BUN Test) confints=quantile(z, c(0.025,0.975)) abline(v=confints, col=blue) #draw a line for each cutoffs abline(v=exptdiff, col=red) Thanks! L.Serieys __ 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] Randomized Points in space/ saving model results
A bit new to R and I'm working on something a bit more challenging than I am used to- so here's whats going on: Data inputs: 9 different shapefiles (.shp) of different point locations (lat, long) shapefile bounding box (lat/long corner points (14, 1) (15,1) (14, 2) (15,2)) 1 .csv of lat/long coordinates for points Goal: a- I want to randomly drop x number of points in a study area within the bounding box b- Then I want to add the .csv points to the mix c- Measure the distances from all these points to each of the 9 shapefiles locations, one at a time and save the results in a table or list d- run an regression analysis on the table or list created (I have this code all set to go) e- I want to save the outputs of the model in a new table (I have this code also) f- Run this whole process again x number of times and save x number of outputs in the table in order of creation Any help on steps a, b,c, or f would be appreciated M. -- View this message in context: http://r.789695.n4.nabble.com/Randomized-Points-in-space-saving-model-results-tp3922612p3922612.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] Survival analysis
Hi, On Thu, Oct 20, 2011 at 2:04 PM, Cem Girit gi...@biopticon.com wrote: Hello, I need some results from the survival analysis of my data that I do not know whether exist in Survival Package or how to obtain if they do: 1. The Mean survival time 2. The standard error of the mean 3. Point and 95% Lower Upper Confidence Intervals estimates Any help will be greatly appreciated. Since we don't know anything about your data or what you've tried, probably the best thing for you to do is do some reading on your own, then come back to the list when you have a specific question. If you go to www.rseek.org and search for survival analysis, you will find a great deal of R information on that topic. It's a good place to start. Sarah -- Sarah Goslee http://www.functionaldiversity.org __ 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] effect function in the effects package
Dear Xu Jun, It's really not possible for me to know the source of the error without a complete, reproducible example, but if I had to guess, I'd guess that there's a scoping problem of some sort, with the value of yr89 coming from somewhere that you don't expect. How about fitting the original model using the data argument rather than allowing the variables in the model to be found along the search path? Best, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 14:09:28 -0400 Xu Jun junx...@gmail.com wrote: Dear Professor Fox, I didn't include codes in between these two commands (polr and plot(effect()). I am still trying to work it out. Maybe it's related to how I coded some of the factor variables as I got some successful runs after I changed the coding for some factor variables. I will keep working on the codes and see if I can figure out. Again, your effects package, I have to say, is awesome! Jun On Thu, Oct 20, 2011 at 1:26 PM, Xu Jun junx...@gmail.com wrote: Dear Professor Fox, Thanks a lot! That is an embarrassing error. After I cleaned up and simplified my codes, and ran the following two lines: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5 I am still having trouble. See below: summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5 Error in plot(effect(age, myologit, xlevels = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') On Thu, Oct 20, 2011 at 11:55 AM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825
[R] identifying groups in xyplot
There have been posts in the past regarding similar questions, but many of them looked dated. I am using xyplot to show variability within my replicates, and so far so good, but I would like to refine the plot. I've used the code below to graph my response variable against year (coded as a factor with three levels 2009, 2010, 2011). Each replicate is in a different panel (|field). My group variable is a factor (Management) with three levels. I would like to define the symbol and color of each factor level. xyplot(Hill.s.diversity ~ Year| Field, group=Management, layout=c(2,3), main=Hills evenness by Management Block, June 2009-2011, ylab=Hills evenness, data=summer_pr_avg) -- View this message in context: http://r.789695.n4.nabble.com/identifying-groups-in-xyplot-tp3922985p3922985.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] effect function in the effects package
Dear Professor Fox, Now I got it. It all comes from my unfamiliarity with the effect function. I forgot the c part in the given.values option, plus it looks like plot(effect()) does not like factor(warm) in the polr function. So here are the two working lines: ordwarm2$warm2 - as.factor(ordwarm2$warm) myologit - polr(warm2 ~ yr89 + male + white + age + ed + prst, data=ordwarm2, method=c(logistic)) plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5)), given.values=(c(male=1, yr89=1 Again, thanks a lot for your effects package that makes graphing so much easier. Jun On Thu, Oct 20, 2011 at 11:55 AM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ 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] effect function in the effects package
Dear Xu Jun, On Thu, 20 Oct 2011 14:41:30 -0400 Xu Jun junx...@gmail.com wrote: Dear Professor Fox, Now I got it. It all comes from my unfamiliarity with the effect function. I forgot the c part in the given.values option, plus it looks like plot(effect()) does not like factor(warm) in the polr function. So here are the two working lines: ordwarm2$warm2 - as.factor(ordwarm2$warm) Without the data, I have no idea what's going on here; the implication is that warm wasn't a factor. myologit - polr(warm2 ~ yr89 + male + white + age + ed + prst, data=ordwarm2, method=c(logistic)) plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5)), given.values=(c(male=1, yr89=1 given.values is an argument. c() is a standard R function for combining values into a vector (or a list); it is not particular to the effects package. The parentheses around (c(male=1, yr89=1)) are entirely unnecessary, and the call to c() in c(logistic) does nothing. Best, John Again, thanks a lot for your effects package that makes graphing so much easier. Jun On Thu, Oct 20, 2011 at 11:55 AM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Are they fully identical: WinBUGS and OpenBUGS; R2WinBUGS and R2OpenBUGS
Petar Milin pmilin at ff.uns.ac.rs writes: Hello ALL! I am running Linux, Fedora 15 64-bits, and R on it. I need to use WinBUGS and R2WinBUGS, but as far as I read, WinBUGS is closed project, to be continued with/as OpenBUGS. Thus, I have found R2OpenBUGS on OpenBUGS Contributed Code (http://openbugs.info/w/UserContributedCode), not on CRAN. Author(s) states that it is equivalent for R2WinBUGS. I tried briefly, and realized few minor differences. However, it seems to work. I wonder if anyone checked thoroughly equivalence of WinBUGS and OpenBUGS, and R2WinBUGS and R2OpenBUGS. Please, share your experience with us! See http://www.openbugs.info/w/OpenVsWin for differences between Open- and WinBUGS. Lots of people still use WinBUGS/R2WinBUGS on Linux, via WINE ... The BUGS ecosystem is a little more complicated than it used to be (with the existence of OpenBUGS and JAGS in addition to WinBUGS, and the addition of BRugs, R2OpenBUGS, rjags, R2jags interfaces to the R2WinBUGS interface). I don't know of any systematic comparisons, though. good luck, Ben Bolker __ 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] Aggregating data help
Hello, I have a dataset with student performance on a math test. There are multiple cases for each student (identified by id) and the concept as a variable. rtest id test subject gradeconcept correct tested per_corr year 11 83 Mathema 8 8.2.D 11 100 2011 21 83 Mathema 8 8.3.A 12 50 2011 31 83 Mathema 8 8.3.B 22 100 2011 41 83 Mathema 8 8.4 22 100 2011 51 83 Mathema 8 8.5.A 12 50 2011 61 83 Mathema 8 8.5.B 020 2011 72 83 Mathema 8 8.2.D 11 100 2011 82 83 Mathema 8 8.3.A 22 100 2011 92 83 Mathema 8 8.3.B 12 50 2011 10 2 83 Mathema 8 8.4 22 100 2011 11 2 83 Mathema 8 8.5.A 1 2 50 2011 12 2 83 Mathema 8 8.5.B 0 20 2011 I would like to make a variable for each concept (e.g. 8.2D, 8.3.A, 8.3B) and then put that percentage correct currently under per_corr for that variable. Such as id testsubject grade 8.2D 8.3.A 8.3.B year 11 83 Mathema 8 10050100 2011 22 83 Mathema 8 100 10050 2011 Does anybody have an effcient way of doing this? What trips me up is handling the variables such as test and subject. Thank you, James [[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] effect function in the effects package
Dear Prof. Fox, I just picked up R not long ago, and apologize that I am not that familiar with some basics. I am trying to replicate what I can do with Stata in R. Thanks for all your help! On Thu, Oct 20, 2011 at 2:47 PM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, On Thu, 20 Oct 2011 14:41:30 -0400 Xu Jun junx...@gmail.com wrote: Dear Professor Fox, Now I got it. It all comes from my unfamiliarity with the effect function. I forgot the c part in the given.values option, plus it looks like plot(effect()) does not like factor(warm) in the polr function. So here are the two working lines: ordwarm2$warm2 - as.factor(ordwarm2$warm) Without the data, I have no idea what's going on here; the implication is that warm wasn't a factor. myologit - polr(warm2 ~ yr89 + male + white + age + ed + prst, data=ordwarm2, method=c(logistic)) plot(effect(age, myologit, xlevels=list(age=seq(20, 80, 5)), given.values=(c(male=1, yr89=1 given.values is an argument. c() is a standard R function for combining values into a vector (or a list); it is not particular to the effects package. The parentheses around (c(male=1, yr89=1)) are entirely unnecessary, and the call to c() in c(logistic) does nothing. Best, John Again, thanks a lot for your effects package that makes graphing so much easier. Jun On Thu, Oct 20, 2011 at 11:55 AM, John Fox j...@mcmaster.ca wrote: Dear Xu Jun, I'm not sure whether this is the source of the error, but it may help to spell the xlevels argument correctly (it is not xlevles). I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 20 Oct 2011 10:34:30 -0400 Xu Jun junx...@gmail.com wrote: Dear r-help listers, I am using effects to produce an effect plot after the proportional odds logistic regression model. There is no problem for me to estimate the model, but when it comes to the graphing, I was stuck. see the codes below: ## myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) require(effects) plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 ## I got the following error message: Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') the full set of codes: myologit - polr(factor(warm) ~ yr89 + male + white + age + ed + prst, + data=ordwarm2, method=c(logistic)) summary(myologit) Re-fitting to get Hessian Call: polr(formula = factor(warm) ~ yr89 + male + white + age + ed + prst, data = ordwarm2, method = c(logistic)) Coefficients: Value Std. Error t value yr89 0.523912 0.079899 6.557 male -0.733309 0.078483 -9.344 white -0.391140 0.118381 -3.304 age -0.021666 0.002469 -8.777 ed 0.067176 0.015975 4.205 prst 0.006072 0.003293 1.844 Intercepts: Value Std. Error t value 1|2 -2.4654 0.2389 -10.3188 2|3 -0.6309 0.2333 -2.7042 3|4 1.2618 0.2340 5.3919 Residual Deviance: 5689.825 AIC: 5707.825 plot(effect(age, myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1 Warning message: package 'effects' was built under R version 2.13.2 Error in plot(effect(age, myologit, xlevles = list(age = seq(20, 80, : error in evaluating the argument 'x' in selecting a method for function 'plot': Error in model.frame.default(formula = factor(warm) ~ yr89 + male + white + : variable lengths differ (found for 'yr89') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,
Re: [R] Running R with browser without installing anything
Try Googling R Portable Ken Hutchison On Oct 20, 2554 BE, at 2:13 PM, jim holtman jholt...@gmail.com wrote: It runs fine off a flash drive. On Thu, Oct 20, 2011 at 1:29 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, the company I work for has Matlab installed for statistical/mathematical calculations and really not ready to go with R (even installing exe file for R). Therefore I was wondering is it possible to do analysis R using browser like IE, without installing anything? Thanks for your suggestion. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru 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] Scatterplot with the 3rd dimension = color?
Can someone please help me out with this? The ggplot2 suggestion works great but I've spent a few days trying to figure out how to plot 2 variables with it and I'm stuck. Here's my example code: library(ggplot2) #Here's the 1st plot x-rnorm(100) y-rnorm(100) z-rnorm(100) d - data.frame(x,y,z) dg-qplot(x,y,colour=z,data=d) dg + scale_colour_gradient(low=red, high=blue) #Here's the 2nd plot which will delete the 1st plot above but I'd like them to be plotted together x1-rnorm(100) y2-rnorm(100) z3-rnorm(100) d1 - data.frame(x1,y1,z1) dg1 -qplot(x1,y1,colour=z1,data=d1) dg1 + scale_colour_gradient(low=green, high=yellow) I've been trying to get long format working but it just doesn't make any sense to me. Thanks, kb On Oct 17, 3:10 pm, Kerry kbro...@gmail.com wrote: Yes, the qplot works great, but do you know how to allow for multiple plots? I want one variable to be plotted say from blue to red and another say from yellow to green but in the same graph, each having there own separate legends. I've tried print() and arrange() but no luck. Thanks again, kb On Oct 2, 10:42 pm, Ben Bolker bbol...@gmail.com wrote: Duncan Murdoch murdoch.duncan at gmail.com writes: On 11-10-02 1:11 PM, Kerry wrote: I have 3 columns of data and want to plot each row as a point in a scatter plot and want one column to be represented as a color gradient (e.g. larger values being more red). Anyone know the command or package for this? It's not a particularly effective display, but here's how to do it. Use rainbow(101) in place of rev(heat.colors(101)) if you like. x - rnorm(10) y - rnorm(10) z - rnorm(10) colors - rev(heat.colors(101)) zcolor - colors[(z - min(z))/diff(range(z))*100 + 1] plot(x,y,col=zcolor) or d - data.frame(x,y,z) library(ggplot2) qplot(x,y,colour=z,data=d) I agree about the not particularly effective display comment, but if you have two continuous predictors and a continuous response you've got a tough display problem -- your choices are: 1. use color, size, or some other graphical characteristic (pretty far down on the Cleveland hierarchy) 2. use a perspective plot (hard to get the right viewing angle, often confusing) 3. use coplots/small multiples/faceting (requires discretizing one dimension) __ 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-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 code Error : Hybrid Censored Weibull Distribution
Dear Sir/madam, I'm getting a problem with a R-code which calculate Fisher Information Matrix for Hybrid Censored Weibull Distribution. My problem is that: when I take weibull(scale=1,shape=2) { i.e shape1} I got my desired result but when I take weibull(scale=1,shape=0.5) { i.e shape1} it gives error : Error in integrate(int2, lower = 0, upper = t) : the integral is probably divergent. I could not found any theoretical interpretation of it. I'm sending the code : # f3-function(t,r){ #calculation for t1 fb1-function(t,r){ v1-numeric(0) for(j in 1:r){ int1-function(x1){ int_1- (1/p+log(x1/lamda))^2 * j * choose(n,j) * (pweibull(x1,shape=p,scale=lamda))^(j-1) * (1 - pweibull(x1,shape=p,scale=lamda))^(n-j) * dweibull(x1,shape=p,scale=lamda) int_1 } v1[j]-integrate(int1,lower=0,upper=t)$value } sum(v1) } #calculation for t2 fb2-function(t,r){ v2-numeric(0) for(j in 1:r){ int2-function(x2){ int_2- (1/p+log(x2/lamda))*(-p/lamda) * j * choose(n,j) * (pweibull(x2,shape=p,scale=lamda))^(j-1) * (1 - pweibull(x2,shape=p,scale=lamda))^(n-j) * dweibull(x2,shape=p,scale=lamda) int_2 } v2[j]-integrate(int2,lower=0,upper=t)$value } sum(v2) } #calculation for t3 fb3-function(t,r){ v3-numeric(0) for(j in 1:r){ int3-function(x3){ int_3- (p/lamda)^2 * j * choose(n,j) * (pweibull(x3,shape=p,scale=lamda))^(j-1) * (1 - pweibull(x3,shape=p,scale=lamda))^(n-j) * dweibull(x3,shape=p,scale=lamda) int_3 } v3[j]-integrate(int3,lower=0,upper=t)$value } sum(v3) } a-c(fb1(t,r),fb2(t,r),fb2(t,r),fb3(t,r)) A-matrix(a,nrow=2,ncol=2,byrow=TRUE) C-solve(A) func1-function(u1){ u11- (log(-log(1-u1)))^2 u11 } m1-(C[1,1]/p^4)*integrate(func1,lower=0,upper=1)$value func2-function(u2){ u22- log(-log(1-u2)) u22 } m2- (-2)*C[1,2]*(1/(p^2 *lamda))*integrate(func2,lower=0,upper=1)$value m3- C[2,2]/lamda^2 m-m1+m2+m3 m } output=f3(5,10) ## Moreover When I consider f3,fb1,fb2,fb3 all are functions of single variable t ,desired results come but in case of two variables the problem arises. Here t is Real Number and r is Integer. I'm suffering this problem since last three months. Please anyone help me out. Thanking you in advance. Regards Ritwik Bhattacharya Senior Research Fellow SQC OR UNIT, KOLKATA INDIAN STATISTICAL INSTITUTE Voice : +91 9051253944 This mail is scanned by Ironport __ 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] bar plot issues
Hi Uwe! 2011/10/20 Uwe Ligges lig...@statistik.tu-dortmund.de: arrange it outside by, e.g. increasing the size of margins (see argument mar in ?par) and place a separate legend (see ?legend) into the margins (see xps argument in ?par). I could not find 'xps', do you mean 'xpd'? This is what I have so far: par(mar=c(5.1,4.1,4.1,12.1)) barplot(t(file.codes), beside = FALSE, legend = FALSE, main=test stacked bar plot, xlab=documents, ylab=number of codes, col=rainbow(ncol(file.codes)), names.arg = rep(NA, nrow(file.codes))) danke, Henri-Paul -- Curriculum Instruction Texas AM University TutorFind Learning Centre Email: hindiog...@gmail.com Skype: hindiogine Website: http://people.cehd.tamu.edu/~sindiogine __ 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] Running R with browser without installing anything
On Thu, Oct 20, 2011 at 7:29 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, the company I work for has Matlab installed for statistical/mathematical calculations and really not ready to go with R (even installing exe file for R). Therefore I was wondering is it possible to do analysis R using browser like IE, without installing anything? Look into RStudio Server. Liviu Thanks for your suggestion. [[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. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Apply approx() to an array and eventually a list of arrays
Hello all, I'm struggling to grasp how I might use lapply() instead of looping to run approx() on a list consisting of multiple arrays - each of equal dimension. But simpler than that, I haven't been able to successfully apply approx() to an array, unless I loop through the third dimension and extract the matrix. See example code below... Any suggestions will be gratefully received. Thanks Michael ### CODE START # build array, create data gaps (i.e. NA's), attempt to apply approx() arr.dim-c(20,3,2) test.arr-array(rnorm(prod(arr.dim)),dim=arr.dim) test.arr.filled-array(NA,dim=arr.dim) test.arr[9:13,1,1]-NA #create some data gaps ### I can only get approx() to work if I loop through third dimension of the array for(i in 1:dim(test.arr)[3]){ test.mat-test.arr[,,i] linear.interp.list-apply(test.mat,MARGIN=2,FUN=approx,xout=1:nrow(test. mat),x=1:nrow(test.mat)) test.arr.filled[,,i]-matrix( sapply(linear.interp.list,'[[','y'),ncol=ncol(test.mat),byrow=FALSE) } How to use approx() on array? # this clearly doesn't work apply(test.arr,MARGIN=2,FUN=approx,xout=1:nrow(test.arr),x=1:nrow(test.a rr)) Now apply approx() to a list of arrays? # build list of 2 arrays of equal dim, create NA's, attempt to apply approx() arr.dim-c(20,3,2) test.list-list(a=array(rnorm(prod(arr.dim)),dim=arr.dim),b=array(rnorm( prod(arr.dim)),dim=arr.dim)) test.list[['a']][9:13,1,1]-NA xout-1:nrow(test.list[['a']]) lapply(test.list, FUN=approx,xout=xout) # clearly doesn't work # CODE END ___ Michael Folkes Salmon Stock Assessment Canadian Dept. of Fisheries Oceans Pacific Biological Station 3190 Hammond Bay Rd. Nanaimo, B.C., Canada V9T-6N7 Ph (250) 756-7264 Fax (250) 756-7053 michael.fol...@dfo-mpo.gc.ca __ 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] quantmod package
Generally getting intraday/real-time data requires some sort of (paid) source, but if you are willing to just strip free quotes off the internet non-stop, perhaps something like this: while(TRUE) { cat( file = FileName.txt, c(getQuote(YHOO), recursive = T), \n, append = T) } # You could get better performance from a textConnection depending on how often you intend to do this You'll have to read.table() the .txt file into an xts before being able to apply most of the quantmod bells and whistles to it. Look at chartSeries() for the graphical stuff. As far as combining them, you could put a chartSeries() command in the loop, but that's going to slow things down since it will require recharting each time. Michael On Thu, Oct 20, 2011 at 3:03 AM, ATANU ata.s...@gmail.com wrote: i am new to the quantmod package . so if the answer is trivial please excuse me. i want to study stock values within a day. i get current stock updates using getQuotes and then want to produce usual quantmod graphs with that values. also the graph should be able of adding technical indicators. please help. in addition it will be helpful if anyone suggests how to run that code continuously to get constantly updated charts. thanks in advance for any suggestion. -- View this message in context: http://r.789695.n4.nabble.com/quantmod-package-tp3921071p3921071.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Survival analysis
Hi, Please send your information to the r-help list, not just to me, but do note that the list is plain-text only. But surely all you are looking for is: dt-c(37,41,40,38,38,37,44,45,48,43,48,46,54,60,32,45,55,62,42,62,62,62,47,42,59,43,60,60,51,43,50,51,47,42,47,51) mean(dt) [1] 48.16667 sd(dt)/sqrt(length(dt)) [1] 1.404923 I have no idea what bizarre formula SAS uses to calculate standard error, but the means match. And you'll note that the lengthy R output you pasted in works just fine, and *does* include the standard errors and confidence limits *of the groups you specified* in your formula. Maybe one of the excellent introduction to R guides available online would be of use to you. Good luck, Sarah On Thu, Oct 20, 2011 at 3:22 PM, Cem Girit gi...@comcast.net wrote: Hello Sarah, Thank you for useful reply. I now know how I can search R world. Google searchers were not useful. I have an efficacy study in which there are 1 control and 3 treatment groups. The survival event, date of events, and group data are in v, d, and g variables (see below). I am using the Survival package. In SAS it is possible to calculate the mean and standard error of the survival times (see an example of SAS output (if it is viewed as html)). I used the “survfit” function from this package together with the print or the summary options but I could not get any results for these parameters. Although, the print function help states that I should get the mean and the error and none of the examples in the print.survfit help file worked! I want to calculate these two parameters by any means in R. Could you help me on this? Thank you. Sincerely, Cem Summary Statistics for Time Variable time Mean Standard Error 48. 2.6931 vT-c(1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,0) dt-c(37,41,40,38,38,37,44,45,48,43,48,46,54,60,32,45,55,62,42,62,62,62,47,42,59,43,60,60,51,43,50,51,47,42,47,51) gT-factor(c(Vehicle,Vehicle,Vehicle,Vehicle,Vehicle,Vehicle,Vehicle,Vehicle,Vehicle,DrugA,DrugA,DrugA,DrugA,DrugA,DrugA,DrugA,DrugA,DrugA,DrugB,DrugB,DrugB,DrugB,DrugB,DrugB,DrugB,DrugB,DrugB,DrugC,DrugC,DrugC,DrugC,DrugC,DrugC,DrugC,DrugC,DrugC)) fit-survfit(Surv(dT,vT)~gT) fit Call: survfit(formula = Surv(dT, vT) ~ gtT) records n.max n.start events median 0.95LCL 0.95UCL gtT=DrugA 9 9 9 6 48 45 NA gtT=DrugB 9 9 9 3 NA 43 NA gtT=DrugC 9 9 9 4 NA 47 NA gtT=Vehicle 9 9 9 8 40 38 NA print(fit,print.n=getOption(survfit.print.n), show.rmean=getOption(survfit.print.mean)) Call: survfit(formula = Surv(dT, vT) ~ gtT) records n.max n.start events median 0.95LCL 0.95UCL gtT=DrugA 9 9 9 6 48 45 NA gtT=DrugB 9 9 9 3 NA 43 NA gtT=DrugC 9 9 9 4 NA 47 NA gtT=Vehicle 9 9 9 8 40 38 NA summary(fit) Call: survfit(formula = Surv(dT, vT) ~ gtT) gtT=DrugA time n.risk n.event survival std.err lower 95% CI upper 95% CI 32 9 1 0.889 0.105 0.706 1.000 43 8 1 0.778 0.139 0.549 1.000 45 7 1 0.667 0.157 0.420 1.000 46 6 1 0.556 0.166 0.310 0.997 48 5 1 0.444 0.166 0.214 0.923 55 3 1 0.296 0.164 0.100 0.875 gtT=DrugB time n.risk n.event survival std.err lower 95% CI upper 95% CI 42 9 2 0.778 0.139 0.549 1 43 7 1 0.667 0.157 0.420 1 gtT=DrugC time n.risk n.event survival std.err lower 95% CI upper 95% CI 42 9 1 0.889 0.105 0.706 1.000 43 8 1 0.778 0.139 0.549 1.000 47 7 2 0.556 0.166 0.310 0.997 gtT=Vehicle time n.risk n.event survival std.err lower 95% CI upper 95% CI 37 9 2 0.778 0.139 0.5485 1.000 38 7 2 0.556 0.166 0.3097 0.997 40 5 1 0.444 0.166 0.2141 0.923 41 4 1 0.333 0.157 0.1323 0.840 44 3 1 0.222 0.139 0.0655 0.754 45 2 1 0.111 0.105 0.0175 0.705 Cem Cem Girit 56 Marion Drive Plainsboro, NJ 08536 Tel: (609) 275 0321 Email:gi...@comcast.net -Original Message- From: Sarah Goslee [mailto:sarah.gos...@gmail.com] Sent: Thursday, October 20, 2011 2:20 PM To: Cem
[R] apply with function
(Iske - matrix(c(1, 1, 1, 2, 2, 2, 10, 1, 1, 5, 1,2,2,2,1,1,1,4,4,4,4,3,3,3,30,3,3,3,3,3,3,3,5,4,4,4,4,4,44,2,2,2,2,4,5,5,5,5,5,5,5,5,95,1,2), ncol = 5)) numtochar - function(Zahl){ text - rawToChar(as.raw(Iske[1,]))} (Iske.char[]-apply(Iske,1,numtochar)) I have a little problem with the command apply(). I want use the function numtochar for every row and the result should be a vector with the chars for every row. At the moment the function numtorow create a char with all items, but separate not every row. I think the function apply is the right way, bu I did not know how to use it at this example. Attention: At the real data set every row have a other length (!) __ 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] apply with function
Does this work? apply(Iske, 1, function(x) rawToChar(as.raw(x))) apply(Iske, 1, function(x) rawToChar(as.raw(x))) [1] \001\002\003\004\005 \001\002\003\004\005 \001\002\036\004\005 [4] \002\001\003\004\005 \002\001\003\004\005 \002\001\003,\005 [7] \n\004\003\002\005 \001\004\003\002\005 \001\004\003\002_ [10] \005\004\003\002\001 \001\003\005\004\002 Michael On Thu, Oct 20, 2011 at 5:20 PM, Jörg Reuter jo...@reuter.at wrote: (Iske - matrix(c(1, 1, 1, 2, 2, 2, 10, 1, 1, 5, 1,2,2,2,1,1,1,4,4,4,4,3,3,3,30,3,3,3,3,3,3,3,5,4,4,4,4,4,44,2,2,2,2,4,5,5,5,5,5,5,5,5,95,1,2), ncol = 5)) numtochar - function(Zahl){ text - rawToChar(as.raw(Iske[1,]))} (Iske.char[]-apply(Iske,1,numtochar)) I have a little problem with the command apply(). I want use the function numtochar for every row and the result should be a vector with the chars for every row. At the moment the function numtorow create a char with all items, but separate not every row. I think the function apply is the right way, bu I did not know how to use it at this example. Attention: At the real data set every row have a other length (!) __ 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] p-val issue for ranked two-group test
Hi, It looks like you are trying to manually bootstrap. Take a look at: require(boot) ?boot as an added advantage of using boot instead of trying to do it manually, you can easily parallelize. In fact, if you are using one of the pre-release versions of 2.14.0, the new parallel package is included by default and you do not even have to go venturing out into the wide world of CRAN to look. That said, there are several aspects of your code that could be readily vectorized. More specific details supplied if a less homework-like example is provided. Cheers, Josh On Thu, Oct 20, 2011 at 10:17 AM, Laurel Klein Serieys laurelkl...@ucla.edu wrote: Hi- I'm wondering if anyone can help me with my code. I'm coming up dry when I try to get a p-value from the following code. If I make a histogram of my resampled distribution, I find the difference between by groups to be significant. I've ranked the data since I have outliers in one of my groups. mange= c(35, 60, 81, 158, 89, 130, 90, 38, 119, 137, 52, 30, 27, 115, 123, 31, 124, 91) healthy= c(46, 50, 30, 58, 32, 42, 42, 33, 19, 42, 30, 26, 38, 23, 16, 28, 42, 42, 33, 35, 51, 31, 39, 40 , 42, 38, 36, 39, 38) l.mange-length(mange) l.healthy-length(healthy) exptdiff - mean.mange - mean.healthy #the expected difference between between the mean of the ranked groups both.chemistry-c(mange, healthy) #concatenate two vectors into one in preparation for resampling the data both.ranks-rank(both.chemistry) #rank combined data in the case that there are outlying values in the data or the dataset is small reps=1000 z-rep(NA,reps) # z will the the simulated storage value for the resampling efforts for(i in 1:reps){ #create the loop x- sample(both.ranks, length(both.ranks),replace=FALSE) #instructions for how to resample where sample the entire combined data without replacment p.mange-mean(x[(1:l.mange)]) #create a simulate mean value for the resampled mange values p.healthy-mean(x[(l.mange+1):(l.mange+l.healthy)]) #create a simulated mean value for the resampled healthy values pdiff- p.mange-p.healthy #the simulated difference between groups z[i]- pdiff #the stored list of simulated differences } p=mean(z=exptdiff)*2 #2-tailed test multiply by two p hist(z, xlab=Resample Values, main=Distribution for Two-Group BUN Test) confints=quantile(z, c(0.025,0.975)) abline(v=confints, col=blue) #draw a line for each cutoffs abline(v=exptdiff, col=red) Thanks! L.Serieys __ 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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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] Calculating differences
I have a table that looks like this: structure(list(speed = c(3,9,4,8,7,6), C = c(0.697, 0.011, 0.015, 0.012, 0.018, 0.019), house = c(1, 1, 1, 1, 1, 1), date = c(719, 1027, 1027, 1027, 1030, 1030), hour = c(18, 8, 8, 8, 11, 11), id = c(1000, 1, 10001, 10002, 10003, 10004)), .Names = c(speed, C, house, date, hour, id), class = data.frame, row.names = c(1000, 1, 10001, 10002, 10003, 10004)) I want to determine the minimum speed for each date, and the C that corresponds to that lowest speed.Then I want to make a table that contains all speeds and the difference between C and the lowest C. For example, on the date 1027, the minimum speed is 4 and the C that corresponds to that is 0.015. The new table should contain: speed 8 and C -0.003 speed 9 and C -0.004 speed 7 and C -0.001How do you do this? Thanks, Jeffrey [[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] Randomized Points in space/ saving model results
Not doing much work with spacial stats or shapefiles, I can't help in too much detail, but here are some R commands that might help for each part: a. # This will help you pick random points within your bounded box runif2d - function(n, xmin, xmax, ymin, ymax){ stopifnot(all(xmax xmin, ymax min)) y - runif(n, ymin, ymax) x - runif(n, xmin, xmax) cbind(x,y) } b. take the output of runif2d (which gives a nx2 matrix) and cbind() the csv points on as well c. getdist - function(inpoints, refpoints) { # Takes in two 2 column matrices representing (x,y) coordinates and returns a matrix with all the distance pairs between them stopifnot(all(is.matrix(inpoints), is.matrix(refpoints), dim(inpoints)[2L] == 2L, dim(refpoints)[2L] == 2L)) d - matrix(nrow = nrow(inpoints), ncol = nrow(refpoints)) for (i in seq_along(refpoints)) { d[, i] - rowSums(inpoints-refpoints[i,]^2) } d } f. Wrap everything in a function and use replicate() Do these help? Michael On Thu, Oct 20, 2011 at 1:32 PM, magono nroya...@gmail.com wrote: A bit new to R and I'm working on something a bit more challenging than I am used to- so here's whats going on: Data inputs: 9 different shapefiles (.shp) of different point locations (lat, long) shapefile bounding box (lat/long corner points (14, 1) (15,1) (14, 2) (15,2)) 1 .csv of lat/long coordinates for points Goal: a- I want to randomly drop x number of points in a study area within the bounding box b- Then I want to add the .csv points to the mix c- Measure the distances from all these points to each of the 9 shapefiles locations, one at a time and save the results in a table or list d- run an regression analysis on the table or list created (I have this code all set to go) e- I want to save the outputs of the model in a new table (I have this code also) f- Run this whole process again x number of times and save x number of outputs in the table in order of creation Any help on steps a, b,c, or f would be appreciated M. -- View this message in context: http://r.789695.n4.nabble.com/Randomized-Points-in-space-saving-model-results-tp3922612p3922612.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calculating differences
I'd dont quite get what you are asking, but here's my best guess and you can tweak it go get what you need. I'd do it in two passes since you want two rather unrelated objects. structure(list(speed = c(3,9,4,8,7,6), C = c(0.697, 0.011, 0.015, 0.012, 0.018, 0.019), house = c(1, 1, 1, 1, 1, 1), date = c(719, 1027, 1027, 1027, 1030, 1030), hour = c(18, 8, 8, 8, 11, 11), id = c(1000, 1, 10001, 10002, 10003, 10004)), .Names = c(speed, C, house, date, hour, id), class = data.frame, row.names = c(1000, 1, 10001, 10002, 10003, 10004)) - X tapply(X, X$date, function(d) d$speed - min(d$speed)) tapply(X, X$date, function(d) d$C[which.min(d$speed)]) Michael On Thu, Oct 20, 2011 at 5:56 PM, Jeffrey Joh johjeff...@hotmail.com wrote: I have a table that looks like this: structure(list(speed = c(3,9,4,8,7,6), C = c(0.697, 0.011, 0.015, 0.012, 0.018, 0.019), house = c(1, 1, 1, 1, 1, 1), date = c(719, 1027, 1027, 1027, 1030, 1030), hour = c(18, 8, 8, 8, 11, 11), id = c(1000, 1, 10001, 10002, 10003, 10004)), .Names = c(speed, C, house, date, hour, id), class = data.frame, row.names = c(1000, 1, 10001, 10002, 10003, 10004)) I want to determine the minimum speed for each date, and the C that corresponds to that lowest speed.Then I want to make a table that contains all speeds and the difference between C and the lowest C. For example, on the date 1027, the minimum speed is 4 and the C that corresponds to that is 0.015. The new table should contain: speed 8 and C -0.003 speed 9 and C -0.004 speed 7 and C -0.001How do you do this? Thanks, Jeffrey [[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] Survival analysis
On Oct 20, 2011, at 5:05 PM, Sarah Goslee wrote: Hi, Please send your information to the r-help list, not just to me, but do note that the list is plain-text only. But surely all you are looking for is: dt- c (37,41,40,38,38,37,44,45,48,43,48,46,54,60,32,45,55,62,42,62,62,62,47,42,59,43,60,60,51,43,50,51,47,42,47,51 ) mean(dt) [1] 48.16667 sd(dt)/sqrt(length(dt)) [1] 1.404923 I have no idea what bizarre formula SAS uses to calculate standard error, but the means match. And you'll note that the lengthy R output you pasted in works just fine, and *does* include the standard errors and confidence limits *of the groups you specified* in your formula. Maybe one of the excellent introduction to R guides available online would be of use to you. I suspect that Cem Girit is attempting to use survival::survfit and survival::print.survfit, to get group means. (He also spelled his vT variable differently in two places.) He seems confused about how to offer arguments to the print.rmean and rmean paramters. He had been advised by Therneau to read: ?print.survfit # where the details of the rmean calculation are discussed Both parameters are expecting a value of TRUE to be invoked, and he was both misnaming them and mis-specifying them. Their default values are: getOption('survfit.rmean') NULL getOption(survfit.print.rmean) NULL After changing the name of vt to vT: print(fit,print.rmean=TRUE) Call: survfit.formula(formula = Surv(dT, vT) ~ gT) records n.max n.start events *rmean *se(rmean) median 0.95LCL 0.95UCL gT=DrugA 9 9 9 6 50.0 3.11 48 45 NA gT=DrugB 9 9 9 3 54.8 2.93 NA 43 NA gT=DrugC 9 9 9 4 53.8 2.74 NA 47 NA gT=Vehicle 9 9 9 8 42.3 2.38 40 38 NA * restricted mean with upper limit = 61 If an overall rmean were desired it would be obtained thusly: print(fit,print.rmean=TRUE) Call: survfit.formula(formula = Surv(dT, vT) ~ 1) records n.maxn.start events *rmean *se(rmean) median 36.0 36.0 36.0 21.0 50.5 1.7 47.0 0.95LCL0.95UCL 43.0 NA * restricted mean with upper limit = 62 -- David Winsemius, MD 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] Randomized Points in space/ saving model results
On 21/10/11 06:32, magono wrote: A bit new to R and I'm working on something a bit more challenging than I am used to- so here's whats going on: Data inputs: 9 different shapefiles (.shp) of different point locations (lat, long) shapefile bounding box (lat/long corner points (14, 1) (15,1) (14, 2) (15,2)) 1 .csv of lat/long coordinates for points Goal: a- I want to randomly drop x number of points in a study area within the bounding box b- Then I want to add the .csv points to the mix c- Measure the distances from all these points to each of the 9 shapefiles locations, one at a time and save the results in a table or list d- run an regression analysis on the table or list created (I have this code all set to go) e- I want to save the outputs of the model in a new table (I have this code also) f- Run this whole process again x number of times and save x number of outputs in the table in order of creation Any help on steps a, b,c, or f would be appreciated. I believe that the tools available in the spatstat package would be of use to you. Read the vignette Handling shapefiles in the spatstat package to find out how to convert shapefile objects to objects of classes with which spatstat can deal. cheers, Rolf Turner __ 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] p-val issue for ranked two-group test
On Oct 20, 2011, at 23:48 , Joshua Wiley wrote: Hi, It looks like you are trying to manually bootstrap. Nope. It's a manually performed approximate Wilcoxon test. Which is fair enough if the object is to learn something. (Notice, however, that the ExactRankTests package eats this sort of problem for breakfast.) As for the actual code, the problem seems mainly to be unclear thinking. The most glaring problem is that exptdiff is never actually calculated, but even if it were, it wouldn't be what the comment says that it is. If it was, it would logically be zero since the expected mean rank is the same in both groups (under the null, but what else could be meant?). More likely the intention is to calculate the _observed_ difference in the mean rank, as is done for pdiff (what does p stand for??) inside the loop, but based on both.ranks rather than on x. With clarified thinking, I'd expect things to fall into place rather easily. Take a look at: require(boot) ?boot as an added advantage of using boot instead of trying to do it manually, you can easily parallelize. In fact, if you are using one of the pre-release versions of 2.14.0, the new parallel package is included by default and you do not even have to go venturing out into the wide world of CRAN to look. That said, there are several aspects of your code that could be readily vectorized. More specific details supplied if a less homework-like example is provided. Cheers, Josh On Thu, Oct 20, 2011 at 10:17 AM, Laurel Klein Serieys laurelkl...@ucla.edu wrote: Hi- I'm wondering if anyone can help me with my code. I'm coming up dry when I try to get a p-value from the following code. If I make a histogram of my resampled distribution, I find the difference between by groups to be significant. I've ranked the data since I have outliers in one of my groups. mange= c(35, 60, 81, 158, 89, 130, 90, 38, 119, 137, 52, 30, 27, 115, 123, 31, 124, 91) healthy= c(46, 50, 30, 58, 32, 42, 42, 33, 19, 42, 30, 26, 38, 23, 16, 28, 42, 42, 33, 35, 51, 31, 39, 40 , 42, 38, 36, 39, 38) l.mange-length(mange) l.healthy-length(healthy) exptdiff - mean.mange - mean.healthy #the expected difference between between the mean of the ranked groups both.chemistry-c(mange, healthy) #concatenate two vectors into one in preparation for resampling the data both.ranks-rank(both.chemistry) #rank combined data in the case that there are outlying values in the data or the dataset is small reps=1000 z-rep(NA,reps) # z will the the simulated storage value for the resampling efforts for(i in 1:reps){ #create the loop x- sample(both.ranks, length(both.ranks),replace=FALSE) #instructions for how to resample where sample the entire combined data without replacment p.mange-mean(x[(1:l.mange)]) #create a simulate mean value for the resampled mange values p.healthy-mean(x[(l.mange+1):(l.mange+l.healthy)]) #create a simulated mean value for the resampled healthy values pdiff- p.mange-p.healthy #the simulated difference between groups z[i]- pdiff #the stored list of simulated differences } p=mean(z=exptdiff)*2 #2-tailed test multiply by two p hist(z, xlab=Resample Values, main=Distribution for Two-Group BUN Test) confints=quantile(z, c(0.025,0.975)) abline(v=confints, col=blue) #draw a line for each cutoffs abline(v=exptdiff, col=red) Thanks! L.Serieys __ 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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] identifying groups in xyplot
Hi, Just include pch=c(1,2,3), col=c('red','blue','yellow') or your choices in xyplot Weidong Gu On Thu, Oct 20, 2011 at 2:15 PM, wisc_maier cmai...@wisc.edu wrote: There have been posts in the past regarding similar questions, but many of them looked dated. I am using xyplot to show variability within my replicates, and so far so good, but I would like to refine the plot. I've used the code below to graph my response variable against year (coded as a factor with three levels 2009, 2010, 2011). Each replicate is in a different panel (|field). My group variable is a factor (Management) with three levels. I would like to define the symbol and color of each factor level. xyplot(Hill.s.diversity ~ Year| Field, group=Management, layout=c(2,3), main=Hills evenness by Management Block, June 2009-2011, ylab=Hills evenness, data=summer_pr_avg) -- View this message in context: http://r.789695.n4.nabble.com/identifying-groups-in-xyplot-tp3922985p3922985.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregating data help
Hi: Here's a way using the reshape2 package. library('reshape2') rsub - subset(rtest, concept %in% c('8.2.D', '8.3.A', '8.3.B')) # want year ahead of concept in the variable list rsub - rsub[, c(1:4, 9, 5:8)] cast(rsub, id + test + subject + grade + year ~ concept, value_var = 'per_corr') # Using per_corr as value column. Use the value argument to cast to override this choice # id test subject grade year 8.2.D 8.3.A 8.3.B # 1 1 83 Mathema 8 2011 10050 100 # 2 2 83 Mathema 8 2011 100 10050 HTH, Dennis On Thu, Oct 20, 2011 at 11:55 AM, James Holland holland.ag...@gmail.com wrote: Hello, I have a dataset with student performance on a math test. There are multiple cases for each student (identified by id) and the concept as a variable. rtest id test subject grade concept correct tested per_corr year 1 1 83 Mathema 8 8.2.D 1 1 100 2011 2 1 83 Mathema 8 8.3.A 1 2 50 2011 3 1 83 Mathema 8 8.3.B 2 2 100 2011 4 1 83 Mathema 8 8.4 2 2 100 2011 5 1 83 Mathema 8 8.5.A 1 2 50 2011 6 1 83 Mathema 8 8.5.B 0 2 0 2011 7 2 83 Mathema 8 8.2.D 1 1 100 2011 8 2 83 Mathema 8 8.3.A 2 2 100 2011 9 2 83 Mathema 8 8.3.B 1 2 50 2011 10 2 83 Mathema 8 8.4 2 2 100 2011 11 2 83 Mathema 8 8.5.A 1 2 50 2011 12 2 83 Mathema 8 8.5.B 0 2 0 2011 I would like to make a variable for each concept (e.g. 8.2D, 8.3.A, 8.3B) and then put that percentage correct currently under per_corr for that variable. Such as id test subject grade 8.2D 8.3.A 8.3.B year 1 1 83 Mathema 8 100 50 100 2011 2 2 83 Mathema 8 100 100 50 2011 Does anybody have an effcient way of doing this? What trips me up is handling the variables such as test and subject. Thank you, James [[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.
[R] xyplot() or splom()?: two factors from same data frame
I'm not seeing how to plot the quantities associated with two values of a factor by reading the ?xyplot help page and Deepayan's book. Perhaps I need to generate many different subsets from the data frame, but that would require _many_ new data frames. The structure of the data frame (for a single stream) has sites (factor), a date (as.Date), parameters (factor), and quantities (numeric). What I need to do is produce scatter plots of the quantities associated with two different parameters conditioned by site or by date (separate plots, I'm sure). I have 24 streams and initially need to look at the relationships of 5 different pairs of parameters (e.g., Cond and TDS) for all sites and by sites. Can I do this from the existing data frame? It seems to me that a splom() could be ideal for this, but I still have the question of how to specify quantities for two parameters to plot against each other. Rich __ 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] Scatterplot with the 3rd dimension = color?
AFAIK, you can't 'add' two ggplot2 graphs together; the problem in this case is that the two color scales would clash. If you're willing to discretize the z values, then you could pull it off. Here's an example: d - data.frame(x = rnorm(100), y = rnorm(100), z = factor(1 + (rnorm(100) 0))) d1 - data.frame(x = rnorm(100), y = rnorm(100), z = factor(3 + (rnorm(100) 0))) dd - rbind(d, d1) In each data frame, I'm assigning two factor levels depending on whether z 0 or not. The factor levels are 1, 2 in d and 3, 4 in d1; when rbinded together, z has four distinct levels. Now call ggplot(): ggplot(dd, aes(x = x, y = y, colour = z)) + geom_point() + scale_colour_manual(values = c('1' = 'red', '2' = 'blue', '3' = 'green', '4' = 'yellow')) This may be coarser than you like, so you could always use the cut() function to discretize z in each data frame; you'll want to assign the levels so that they are distinct in the combined data frame. Example: d3 - data.frame(x = rnorm(100), y = rnorm(100), z = cut(rnorm(100), breaks = c(-Inf, -0.5, 0.5, Inf), labels = 1:3)) d4 - data.frame(x = rnorm(100), y = rnorm(100), z = cut(rnorm(100), breaks = c(-Inf, -0.5, 0.5, Inf), labels = 4:6)) dd2 - rbind(d3, d4) mycols - c('red', 'maroon', 'blue', 'green', 'cyan', 'yellow') ggplot(dd2, aes(x = x, y = y, colour = z)) + geom_point() + scale_colour_manual(breaks = levels(dd2$z), values = mycols) You can always use the labels = argument of scale_colour_manual() to assign more evocative legend values, or equivalently, you can assign the labels in the cut() function within d3 and d4 to those you want in the legend and leave the plot code as is. BTW, there is a dedicated ggplot2 list to which you can subscribe through http://had.co.nz/ggplot2/ (look for the ggplot2 mailing list near the top of the page). The list archives are accessible through the same link. HTH, Dennis On Thu, Oct 20, 2011 at 12:25 PM, Kerry kbro...@gmail.com wrote: Can someone please help me out with this? The ggplot2 suggestion works great but I've spent a few days trying to figure out how to plot 2 variables with it and I'm stuck. Here's my example code: library(ggplot2) #Here's the 1st plot x-rnorm(100) y-rnorm(100) z-rnorm(100) d - data.frame(x,y,z) dg-qplot(x,y,colour=z,data=d) dg + scale_colour_gradient(low=red, high=blue) #Here's the 2nd plot which will delete the 1st plot above but I'd like them to be plotted together x1-rnorm(100) y2-rnorm(100) z3-rnorm(100) d1 - data.frame(x1,y1,z1) dg1 -qplot(x1,y1,colour=z1,data=d1) dg1 + scale_colour_gradient(low=green, high=yellow) I've been trying to get long format working but it just doesn't make any sense to me. Thanks, kb On Oct 17, 3:10 pm, Kerry kbro...@gmail.com wrote: Yes, the qplot works great, but do you know how to allow for multiple plots? I want one variable to be plotted say from blue to red and another say from yellow to green but in the same graph, each having there own separate legends. I've tried print() and arrange() but no luck. Thanks again, kb On Oct 2, 10:42 pm, Ben Bolker bbol...@gmail.com wrote: Duncan Murdoch murdoch.duncan at gmail.com writes: On 11-10-02 1:11 PM, Kerry wrote: I have 3 columns of data and want to plot each row as a point in a scatter plot and want one column to be represented as a color gradient (e.g. larger values being more red). Anyone know the command or package for this? It's not a particularly effective display, but here's how to do it. Use rainbow(101) in place of rev(heat.colors(101)) if you like. x - rnorm(10) y - rnorm(10) z - rnorm(10) colors - rev(heat.colors(101)) zcolor - colors[(z - min(z))/diff(range(z))*100 + 1] plot(x,y,col=zcolor) or d - data.frame(x,y,z) library(ggplot2) qplot(x,y,colour=z,data=d) I agree about the not particularly effective display comment, but if you have two continuous predictors and a continuous response you've got a tough display problem -- your choices are: 1. use color, size, or some other graphical characteristic (pretty far down on the Cleveland hierarchy) 2. use a perspective plot (hard to get the right viewing angle, often confusing) 3. use coplots/small multiples/faceting (requires discretizing one dimension) __ 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-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.
Re: [R] Foreach (doMC)
Jannis, I'm not complete sure I understand your first point, but maybe someone from REvolution will weigh in. Nobody is forcing anyone to purchase any products, and there are attractive alternatives such as the CRAN R and R Studio (to name two). This issue has arisen many times of the various lists and you are welcome to search the archives and read many very intelligent, thoughtful opinions. As for foreach, etc... if you have fairly focused questions (preferably with a reproducible example if there is a problem) and if you have done reading on examples available on using it, then you might try joining the r-sig-...@r-project.org group. Clearly there are far more users of core R and hence mainstream questions on r-help are likely to be answered more quickly (on average) than specialized questions. Regards, Jay On Thu, Oct 20, 2011 at 4:27 PM, Jannis bt_jan...@yahoo.de wrote: Dear list members, dear Jay, Well, I personally do not care about Revolutions Analytics selling their products as this is also included into the idea of many open source licences. Especially as Revolutions provide their packages to the community and its is everybodies personal choice to buy their special R version. I was just wondering about this issue as usually most questions on r-help are answered pretty soon and by many different people and I had the impression that this is not the case for posts regarding the foreach/doMC/doSMP etc packages. This may, however, be also due to the probably limited use of these packages for most users who do not need these high performance computing things. Or it was just my personal perception or pure chance. Thanks however, to the authors of such packages! They were of great help to me on several ocasions and I have deep respect for everybody devoting his time to open source software! Jannis On 10/19/2011 01:26 PM, Jay Emerson wrote: P.S. Is there any particular reason why there are so seldom answers to posts regarding foreach and all these doMC/doSMP packages ? Do so few people use these packages or does this have anything to do with the commercial origin of these packages? Jannis, An interesting question. I'm a huge fan of foreach and the parallel backends, and have used foreach in some of my packages. It leaves the choice of backend to the user, rather than forcing some environment. If you like multicore, great -- the package doesn't care. Someone else may use doSNOW. No problem. To answer your question, foreach was originally written by (primarily, at least) Steve Weston, previously of REvolution Computing. It, along with some of the parallel backends (perhaps all at this point, I'm out of touch) are available open-source. Hence, I'd argue that the commercial origin is a moot point -- it doesn't matter, it will always be available, and it's really useful. Steve is no longer with REvolution, however, and I can't speak for the responsiveness/interest of current REvolution folks on this point. Scanning R-help daily for things relating to my own packages is something I try to do, but it doesn't always happen. I would like to think foreach is widely used -- it does have a growing list of reverse depends/suggests. And was updated as recently as last May, I just noticed. http://cran.r-project.org/web/packages/foreach/index.html Jay -- John W. Emerson (Jay) Associate Professor of Statistics Department of Statistics Yale University http://www.stat.yale.edu/~jay __ 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] Calculating differences
Hi: Here's one way with the plyr package. Using ds as the name of your data frame (thank you for the dput and clear description of what you wanted, BTW), library('plyr') ddply(ds, .(date), mutate, minspd = min(speed), Cmin = C[which.min(speed)], diff = C - Cmin) speed C house date hourid minspd Cmin diff 1 3 0.697 1 719 18 1000 3 0.697 0.000 2 9 0.011 1 10278 1 4 0.015 -0.004 3 4 0.015 1 10278 10001 4 0.015 0.000 4 8 0.012 1 10278 10002 4 0.015 -0.003 5 7 0.018 1 1030 11 10003 6 0.019 -0.001 6 6 0.019 1 1030 11 10004 6 0.019 0.000 HTH, Dennis On Thu, Oct 20, 2011 at 2:56 PM, Jeffrey Joh johjeff...@hotmail.com wrote: I have a table that looks like this: structure(list(speed = c(3,9,4,8,7,6), C = c(0.697, 0.011, 0.015, 0.012, 0.018, 0.019), house = c(1, 1, 1, 1, 1, 1), date = c(719, 1027, 1027, 1027, 1030, 1030), hour = c(18, 8, 8, 8, 11, 11), id = c(1000, 1, 10001, 10002, 10003, 10004)), .Names = c(speed, C, house, date, hour, id), class = data.frame, row.names = c(1000, 1, 10001, 10002, 10003, 10004)) I want to determine the minimum speed for each date, and the C that corresponds to that lowest speed.Then I want to make a table that contains all speeds and the difference between C and the lowest C. For example, on the date 1027, the minimum speed is 4 and the C that corresponds to that is 0.015. The new table should contain: speed 8 and C -0.003 speed 9 and C -0.004 speed 7 and C -0.001How do you do this? Thanks, Jeffrey [[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] xyplot() or splom()?: two factors from same data frame
Hi Rich Without a dataset I am not sure what you need. Further down the track you will need to plot what you finally need and this may help you decide what you need now for finals try library(lattice) library(latticeExtra) useOuterStrips( xyplot(variable1 + variable2 ~ Date|Site, data = Data, groups = Groups, ...) ) this will give you a matrix plot of the columns being the site and the rows being the variables. but for now if you have a large screen you can do a splom by sites you may to subset sites. use par.settings and levelplot settings to reduce the fontsizes etc so that you can get as much information splom( ...|Site, data= Data,...) if you want to have 2 plots eg the x axis as time and another independent variable you can plot them on the page together eg plot1 - xyplot() plot2 - density.plot(...) print(p1, position= c(0,0,1,0.5), more = T) print(p1, position= c(0,0.5,1,1), more = F) see ?print.trellis As usual everything depends on the data HTH Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email Home: mac...@northnet.com.au At 09:41 21/10/2011, you wrote: I'm not seeing how to plot the quantities associated with two values of a factor by reading the ?xyplot help page and Deepayan's book. Perhaps I need to generate many different subsets from the data frame, but that would require _many_ new data frames. The structure of the data frame (for a single stream) has sites (factor), a date (as.Date), parameters (factor), and quantities (numeric). What I need to do is produce scatter plots of the quantities associated with two different parameters conditioned by site or by date (separate plots, I'm sure). I have 24 streams and initially need to look at the relationships of 5 different pairs of parameters (e.g., Cond and TDS) for all sites and by sites. Can I do this from the existing data frame? It seems to me that a splom() could be ideal for this, but I still have the question of how to specify quantities for two parameters to plot against each other. Rich __ 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] p-val issue for ranked two-group test
On Thu, Oct 20, 2011 at 3:42 PM, peter dalgaard pda...@gmail.com wrote: On Oct 20, 2011, at 23:48 , Joshua Wiley wrote: Hi, It looks like you are trying to manually bootstrap. Nope. It's a manually performed approximate Wilcoxon test. Which is fair enough if the object is to learn something. (Notice, however, that the ExactRankTests package eats this sort of problem for breakfast.) You are correct, Peter. Apologies, Laurel, for a hastie read and reply to your email. As for the actual code, the problem seems mainly to be unclear thinking. The most glaring problem is that exptdiff is never actually calculated, but even if it were, it wouldn't be what the comment says that it is. If it was, it would logically be zero since the expected mean rank is the same in both groups (under the null, but what else could be meant?). More likely the intention is to calculate the _observed_ difference in the mean rank, as is done for pdiff (what does p stand for??) inside the loop, but based on both.ranks rather than on x. With clarified thinking, I'd expect things to fall into place rather easily. Take a look at: require(boot) ?boot as an added advantage of using boot instead of trying to do it manually, you can easily parallelize. In fact, if you are using one of the pre-release versions of 2.14.0, the new parallel package is included by default and you do not even have to go venturing out into the wide world of CRAN to look. That said, there are several aspects of your code that could be readily vectorized. More specific details supplied if a less homework-like example is provided. Cheers, Josh On Thu, Oct 20, 2011 at 10:17 AM, Laurel Klein Serieys laurelkl...@ucla.edu wrote: Hi- I'm wondering if anyone can help me with my code. I'm coming up dry when I try to get a p-value from the following code. If I make a histogram of my resampled distribution, I find the difference between by groups to be significant. I've ranked the data since I have outliers in one of my groups. mange= c(35, 60, 81, 158, 89, 130, 90, 38, 119, 137, 52, 30, 27, 115, 123, 31, 124, 91) healthy= c(46, 50, 30, 58, 32, 42, 42, 33, 19, 42, 30, 26, 38, 23, 16, 28, 42, 42, 33, 35, 51, 31, 39, 40 , 42, 38, 36, 39, 38) l.mange-length(mange) l.healthy-length(healthy) exptdiff - mean.mange - mean.healthy #the expected difference between between the mean of the ranked groups both.chemistry-c(mange, healthy) #concatenate two vectors into one in preparation for resampling the data both.ranks-rank(both.chemistry) #rank combined data in the case that there are outlying values in the data or the dataset is small reps=1000 z-rep(NA,reps) # z will the the simulated storage value for the resampling efforts for(i in 1:reps){ #create the loop x- sample(both.ranks, length(both.ranks),replace=FALSE) #instructions for how to resample where sample the entire combined data without replacment p.mange-mean(x[(1:l.mange)]) #create a simulate mean value for the resampled mange values p.healthy-mean(x[(l.mange+1):(l.mange+l.healthy)]) #create a simulated mean value for the resampled healthy values pdiff- p.mange-p.healthy #the simulated difference between groups z[i]- pdiff #the stored list of simulated differences } p=mean(z=exptdiff)*2 #2-tailed test multiply by two p hist(z, xlab=Resample Values, main=Distribution for Two-Group BUN Test) confints=quantile(z, c(0.025,0.975)) abline(v=confints, col=blue) #draw a line for each cutoffs abline(v=exptdiff, col=red) Thanks! L.Serieys __ 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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] stacked plot
Hi! I am trying to use ggplot2 to create a stacked bar plot. Previously I tried using barplot() but gave up because of problems with the positioning of the legend and other appearance problems. I am now trying to learn ggplot2 and use it for all the plots that I need to create for my dissertation. I am able to create normal bar plots using ggplot2, but I am stomped with the stacked bar plots. This works: barplot(t(file.codes), beside = FALSE) the data.frame file.codes looks like this . code.1 code.2 code.3 code.4 code.5 file.1 2 0 0 54 file.2 3 18 1 02 I would like each file to be a bar and then each code stacked for each file.By transposing the file.codes data.frame barplot() will allow me to do so. I am trying to obtain the same result in ggplot2 but i think that qplot wants the data to be like this: file.1 code.1 2 file.1 code.2 0 file.1 code.3 0 file.1 code.4 5 file.1 code.5 4 file.2 code.1 3 file.2 code.2 18 I think that I need to use the package reshape, but I am not sure whether to use cast(), melt(), or recast() and how to set up the function. Thanks, Henri-Paul -- Henri-Paul Indiogine Curriculum Instruction Texas AM University TutorFind Learning Centre Email: hindiog...@gmail.com Skype: hindiogine Website: http://people.cehd.tamu.edu/~sindiogine __ 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] Change column/row-name
Hi, I am very happy. My problems are solved without one little thing: (Iske - matrix(c(1, 1, 1, 2, 2, 2, 1, 1, 1, 5, 1, 2, 2, 2, 1, 1, 1, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2), ncol = 5)) #My Matrix Iske- Iske+33 #I want see the letters (Iske.char-apply(Iske, 1, function(x) rawToChar(as.raw(x #Numbers to Char LD - function(s1, s2){ require(vwr) s1 = as.character(s1) s2 = as.character(s2) t(sapply(s1, levenshtein.distance, s2)) } Iske.levens-(LD(Iske.char,Iske.char)) #Calculate the Levenshtein-Distanz The result: !#$% !#$% !#$% !#$% !#$% 0 0 0 !#$% 0 0 0 !#$% 0 0 0 . . . It is all beautiful. But is there a simple way to change the column/row-name to the original from the Matrix Iske? Thanks a lot for the help yesterday. It was a big step in my life :-) __ 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.