[R] Fractional component of a number
Dear all, I am happy to accept that is.integer(1) [1] FALSE But I'm having difficulty with this one: as.integer((2.53-2)*100) [1] 52 especially since: as.integer((1.53-1)*100) [1] 53 Although I know that this is a precision issue since x - (2.53-2)*100 x-53 [1] -2.131628e-14 And I can always use the round function to get what I want, but I just wonder if something is wrong here. sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Thai_Thailand.874 LC_CTYPE=Thai_Thailand.874 LC_MONETARY=Thai_Thailand.874 [4] LC_NUMERIC=C LC_TIME=Thai_Thailand.874 attached base packages: [1] stats graphics grDevices utils datasets methods base Thanks, Edward -- NOTE: Prince of Songkla University will NEVER ask for your PSU Passport/Email Username or password by e-mail. If you receive such a message, please report it to report-ph...@psu.ac.th. NEVER reply to any email asking for your PSU Passport/Email or other personal details. @ For more information, contact the PSU E-Mail Service by dialing 2121 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Ordered probit model -marginal effects and relative importance of each predictor-
On Aug 27, 2011 franco salerno wrote: ...problem with ordered probit model -polr function (library MASS). a) how to calculate marginal effects b) how to calculate the relative importance of each independent variables Hi Franco, Have a look at John Fox's effects package (for a), and the Anova() function in his car package (for b). 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/Ordered-probit-model-marginal-effects-and-relative-importance-of-each-predictor-tp3773504p3774060.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] Fractional component of a number
On 28-Aug-11 03:59:51, edwar...@psu.ac.th wrote: Dear all, I am happy to accept that is.integer(1) [1] FALSE But I'm having difficulty with this one: as.integer((2.53-2)*100) [1] 52 especially since: as.integer((1.53-1)*100) [1] 53 Although I know that this is a precision issue since x - (2.53-2)*100 x-53 [1] -2.131628e-14 And I can always use the round function to get what I want, but I just wonder if something is wrong here. sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Thai_Thailand.874 LC_CTYPE=Thai_Thailand.874 LC_MONETARY=Thai_Thailand.874 [4] LC_NUMERIC=C LC_TIME=Thai_Thailand.874 attached base packages: [1] stats graphics grDevices utils datasets methods base Thanks, Edward It depends on what you mean by wrong! Perhaps unexpected might be better! The key to the matter is described in '?as.integer' under Value: Non-integral numeric values are truncated towards zero (i.e., ?as.integer(x)? equals ?trunc(x)? there) ... so that as.integer(2) # [1] 2 as.integer(2 + 2e-14) # [1] 2 as.integer(2 - 2e-14) # [1] 1 as.integer(-2 + 2e-14) # [1] -1 as.integer(-2 - 2e-14) # [1] -2 so it is doing what it says on the box. Yes, you are better using round()! Hoping this helps to clear it up, Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 28-Aug-11 Time: 09:24:14 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to get url content with ? (question mark) inside
There is an url http://www.ozon.ru/context/detail/id/5254326/?type=6#buyalso; If I try to get the data there (by readLines or whatever), R downloads actually the content of this url http://www.ozon.ru/context/detail/id/5254326; that is till the question mark. What should I do to avoid the problem? Thanks! Philipp __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 add a legend to a goodness-of-fit plot (vcd:goodfit)?
Hello, Sample code: library(vcd) dummy - rnbinom(200, size=1.5, prob=0.8) gf - goodfit(dummy, type=nbinomial, method=MinChisq) plot(gf) I would like to: 1. add a lgened stating the bars show the actual counts and the red dots - the fit. 2. show the goodness-of-fit values calculated somewhere on an empty white space ob the plot. But... the legend command does not work. Any help? Thanks, Dave __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fractional component of a number
FAQ 7.31 Sent from my iPad On Aug 27, 2011, at 23:59, edwar...@psu.ac.th wrote: Dear all, I am happy to accept that is.integer(1) [1] FALSE But I'm having difficulty with this one: as.integer((2.53-2)*100) [1] 52 especially since: as.integer((1.53-1)*100) [1] 53 Although I know that this is a precision issue since x - (2.53-2)*100 x-53 [1] -2.131628e-14 And I can always use the round function to get what I want, but I just wonder if something is wrong here. sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Thai_Thailand.874 LC_CTYPE=Thai_Thailand.874 LC_MONETARY=Thai_Thailand.874 [4] LC_NUMERIC=C LC_TIME=Thai_Thailand.874 attached base packages: [1] stats graphics grDevices utils datasets methods base Thanks, Edward -- NOTE: Prince of Songkla University will NEVER ask for your PSU Passport/Email Username or password by e-mail. If you receive such a message, please report it to report-ph...@psu.ac.th. NEVER reply to any email asking for your PSU Passport/Email or other personal details. @ For more information, contact the PSU E-Mail Service by dialing 2121 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Text mining analysis methods
Hi all, i am trying to do some text mining in R. So far I managed to do some text mining like TermDocumentMatrices and word count and similiar things. What I would like to do is this : I have a soil descriptions from borehole logs that corresponds to soil classes. The problem is that some of this classes are wrongly classified. What i did is i made DocumenstTermMatrices for each of the class. So now i would like to use some king of statistical method to determine to which of the classes they actually belong. Hope that explains it. Any help of info would be grately appreciated, matevz -- View this message in context: http://r.789695.n4.nabble.com/Text-mining-analysis-methods-tp3774283p3774283.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] Degrees of freedom in the Ljung-Box test
I think now everything should be fine and the problem should disappear. And now about my problem. 'x' is not a set of residuals from an ARMA fit. I just have 982 weekly quotations of a given stock index and I want to run a Ljung-Box test on these data to test for autocorrelation. So 'x' would be exactly this time series of 982 quotations. I need the results of the Ljung-Box test for the table of descriptive statistics in which I also have mean, st. deviation, skewness, kurtosis and Jarque-Bera. The only problem is that I do not know what should be the value of 'lag' in the formula Box.test. I found an article where authors have daily quotations and they apply Ljung-Box Q-test statistics with up to 10-day lags ( LB(10) ). They do it for 1213 observations as well as for 671 and 542 observations. I do not understand why did they choose 10-day lags.. I hope now everything is clear... Regards Marcin 2011/8/27 Prof Brian Ripley rip...@stats.ox.ac.uk Please fix your email settings: your 'From:' field is not in the correct encoding, so I had to manually copy the ASCII part. (The header as received here said it was UTF-8, but it is not valid UTF-8. Most likely no encoding was declared your end.) On Sat, 27 Aug 2011, Marcin Pciennik wrote: Dear list members, I have 982 quotations of a given stock index and I want to run a Ljung-Box test on these data to test for autocorrelation. Later on I will estimate 8 coefficients. I do not know how many degrees of freedom should I assume in the formula for Ljung-Box test. Could anyone tell me please? Nor does anyone else without knowing what 'x' is. But from the help page: fitdf: number of degrees of freedom to be subtracted if x is a series of residuals. Details: These tests are sometimes applied to the residuals from an ARMA(p, q) fit, in which case the references suggest a better approximation to the null-hypothesis distribution is obtained by setting fitdf = p+q, provided of course that lag fitdf. So is 'x' a set of residuals from an ARMA fit? If so, the help page told you how, and if it is a not a fit note the word 'if' in the description of 'fitdf'. Below the formula: Box.test(x, lag = , type = c(Ljung-Box), fitdf = 0) Thank you very much in advance. Best regards Marcin [[alternative HTML version deleted]] Please don't send HTML as you were explicitly asked in the posting guide. Very likely that exacerbated the encoding confusion. PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~**ripley/http://www.stats.ox.ac.uk/%7Eripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[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 add a legend to a goodness-of-fit plot (vcd:goodfit)?
David Breimann david.breimann at gmail.com writes: Hello, Sample code: library(vcd) dummy - rnbinom(200, size=1.5, prob=0.8) gf - goodfit(dummy, type=nbinomial, method=MinChisq) plot(gf) I would like to: 1. add a lgened stating the bars show the actual counts and the red dots - the fit. 2. show the goodness-of-fit values calculated somewhere on an empty white space ob the plot. But... the legend command does not work. Please don't cross-post, or if you must explain why ... you already got an answer on StackOverflow ... (broken URL to respect Gmane's line length limit) http://stackoverflow.com/questions/7202163/ how-can-i-add-a-legend-to-a-goodness-of-fit-plot-in-r __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Asking Favor For Remove element with Particular Value In Vector
You can use 'which' and negative subscripts to remove elements from a vector. y-x[-(which(x==0|x==255))] chuan_zl wrote: Dear All. I am Chuan. I am beginner for R.I facing some problem in remove element from vector.I have a vector with size 238 element as follow(a part) [1] 0 18 24 33 44..[238] 255 Let the vector label as x,I want remove element 0 and 255.I try use such function: x[x0 x255] However, I am fail since same results are give even try it for many times.I also try with shorter vector with 10 element. It is successfully resulted. So,want can I do for it. Kindly asking favor for expert here. Thank you very much. Chuan -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3774271.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 with levelplot color assignment in lattice
Dear R users, I'm currently trying to make level plots of a longitudinal study of the spatio-temporal spread of a plant disease in a field, but the results of the color key assignment isn't what I expect. Here's more info. I recorded the level of a disease on an ordinal scale from 0 (no disease) to 9 (dead plant) on a grid that has 9 rows and 14 columns. The disease level on each plant was recorded on a weekly basis, and I what I need is to make a levelplot from each weekly snapshot, and of course the color levels need to be the same to compare images, and ultimately turn this in an animation to visualize the spread of the disease in time and space. In the following code, what I get from levelplot in lattice is a color scale that is not centered, and not correct (I want white for level=0, red for level=9, and yellow shades for intermediate levels). Is there a way to make it look right ? # Example data set from an intermediate snapshot. Note that at the maximal level recorded in this one is 8, but I still want the color key to go up to 9 for comparison with later plots data - data.frame(x=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14),y=rev(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9)),level=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, NA, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 1, 1, 1, 1, 1, 1)) library(lattice) library(grDevices) # For the color palette colpal - colorRampPalette(c(white,yellow,red)) colseq - seq(0,9,by=1) levelplot(level~ x* y, data = data, as.table = TRUE, at = colseq, region = TRUE, col.regions = colpal(10), colorkey = list(at = colseq, labels=list(at=colseq)), xlab=x, ylab=y, strip = strip.custom(factor.levels = c(date 3))) As you should see, instead of having the level 0 polygon in white, and most polygons in the first shade of yellow (level 1), most of them ar white. As an extra, I would like to have the NA data appear as black, but I know I can use lrect do to it. The attached image is from the graph I can obtain from a custom fonction calling the regular plot() and assigning colors to polygons, and color.legend() from package plotrix to generate the color key. It gives me the right kind of color key and colors assignment to polygons (and note how the color key lebaels are centered vertically with regards to the polygons), but the plot() is not as easily customizable as I'd like. I hope you can help me figure it out with lattice. http://r.789695.n4.nabble.com/file/n3774374/levelplot.jpg -- View this message in context: http://r.789695.n4.nabble.com/Help-with-levelplot-color-assignment-in-lattice-tp3774374p3774374.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] read.table: deciding automatically between two colClasses values
Hello, I have a function for reading a data-frame from a file, which contains E = read.table(file = filename, header = T, colClasses = c(rep(integer,6),numeric,integer,rep(numeric,8)), ...) Now a small variation arose, where colClasses = c(rep(integer,4),numeric,integer,rep(numeric,8)) needed to be used (so just a small change). I want to have it convenient for the user, so no user intervention shall be needed, but the function should choose between the two different values 4 and 6 here according to the header-line. Now this seems to be a problem: I found only count.fields, which however is not able just to read the first line. Reading the whole file (just to read the first line) is awkward, and also these files typically have millions of lines. The only possibility to influence count.fields seems via skip, but this I could only use to skip to the last line, which reads the file nevertheless, and I also don't know the number of lines in the file. Perhaps one could catch an error, when the first invocation of read.table fails, and try the second one. However tryCatch doesn't seem to make it simple to write something like E = try(expr1 otherwise expr2) (if expr1 fails, evaluate expr2 instead) ? Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] read.table: deciding automatically between two colClasses values
Hi Oliver, Look at ?readLines I imagine something like: tmp - readLines(filename, n = 1L) (do stuff with the first line to decide) IntN - 6 (or 4) NumN - 8 (or whatever) E - read.table(file = filename, header = TRUE, colClasses = c(rep(integer, IntN), numeric, integer, rep(numeric, NumN)), ...) Cheers, Josh On Sun, Aug 28, 2011 at 7:13 AM, Oliver Kullmann o.kullm...@swansea.ac.uk wrote: Hello, I have a function for reading a data-frame from a file, which contains E = read.table(file = filename, header = T, colClasses = c(rep(integer,6),numeric,integer,rep(numeric,8)), ...) Now a small variation arose, where colClasses = c(rep(integer,4),numeric,integer,rep(numeric,8)) needed to be used (so just a small change). I want to have it convenient for the user, so no user intervention shall be needed, but the function should choose between the two different values 4 and 6 here according to the header-line. Now this seems to be a problem: I found only count.fields, which however is not able just to read the first line. Reading the whole file (just to read the first line) is awkward, and also these files typically have millions of lines. The only possibility to influence count.fields seems via skip, but this I could only use to skip to the last line, which reads the file nevertheless, and I also don't know the number of lines in the file. Perhaps one could catch an error, when the first invocation of read.table fails, and try the second one. However tryCatch doesn't seem to make it simple to write something like E = try(expr1 otherwise expr2) (if expr1 fails, evaluate expr2 instead) ? Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.
Re: [R] Asking Favor For Remove element with Particular Value In Vector
Be careful about negating the 'which' in case there are no matches: x - 1:10 x[-which(x == 11)] integer(0) Notice it deletes the whole vector. Safer to use logical vectors: x[!(x==3 | x == 7)] [1] 1 2 4 5 6 8 9 10 x[!(x == 11)] # notice this works [1] 1 2 3 4 5 6 7 8 9 10 On Sun, Aug 28, 2011 at 7:20 AM, eyildiz engin.yildizt...@gmail.com wrote: You can use 'which' and negative subscripts to remove elements from a vector. y-x[-(which(x==0|x==255))] chuan_zl wrote: Dear All. I am Chuan. I am beginner for R.I facing some problem in remove element from vector.I have a vector with size 238 element as follow(a part) [1] 0 18 24 33 44..[238] 255 Let the vector label as x,I want remove element 0 and 255.I try use such function: x[x0 x255] However, I am fail since same results are give even try it for many times.I also try with shorter vector with 10 element. It is successfully resulted. So,want can I do for it. Kindly asking favor for expert here. Thank you very much. Chuan -- View this message in context: http://r.789695.n4.nabble.com/Asking-Favor-For-Remove-element-with-Particular-Value-In-Vector-tp3772779p3774271.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman 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] Rcmdr help
On 26.08.2011 23:41, Andrés Aragón wrote: Hi, please help me, I want to have a functional Rcmdr but after install as indicated in: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html obtain the following: Loading Tcl/Tk interface ... done Loading required package: car Loading required package: MASS Loading required package: nnet Loading required package: survival Loading required package: splines Error : .onAttach failed in attachNamespace() for 'Rcmdr', details: call: .Call(R_lazyLoadDBfetch, key, file, compressed, hook, PACKAGE = base) error: C symbol name R_lazyLoadDBfetch not in DLL for package base Error: package/namespace load failed for 'Rcmdr' This sounds like your R installation is broken and you use and your R code and the compiled code of different R versions are mixed up. Uwe Ligges I am using R 2.13.1 and Rcmdr 1.7-0 on mac os x 10.6.8. Thanks ahead, Andrés __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Change color in forest.rma (metafor)
On 26.08.2011 15:50, Paola Tellaroli wrote: I lied, that was not my last question: how can I add two arrows at the bottom with the words in favor of A / B? This is not specified in the pdf and with text I have the impression that I can't add text below the x-axis. You can, see ?par and its xpd argument. Uwe Ligges 2011/8/26 Paola Tellarolipaola.tellar...@gmail.com Dear Prof. Viechtbauer, thank you so much for your help and kindness. Clearly graphs are the minor problem in our work, and the parameters and options that can vary in R are so many that it is obvious that you can not expect to change everything you want! Your suggestions are very helpuf, but I have one last question. I'm trying to copy the style of a forest plot that I've seen and I like (the one in the attached file, page 1034): can I do this in R? Best wishes, *Paola* 2011/8/25 Viechtbauer Wolfgang (STAT)-2 [via R] ml-node+3768683-1225159815-262...@n4.nabble.com The color of the squares is also currently hard coded. The thing is, there are so many different elements to a forest plot (squares, lines, polygons, text, axes, axis labels, etc.), if I would add arguments to set the color of each element, things would really get out of hand (as far as I am concerned, there are already too many arguments to begin with). I can think of one possibility: I could allow the col argument to accept a vector of colors and then apply the different elements of that vector to the various elements in the plot. Of course, there is also a limit to how far that can be taken. For example, what if somebody wants to have a different color for *one* of the squares and a different color for the other squares? Another possibility is to do some post-processing with other software. One can create the forest plot in R, save it for example as a postscript file, and the edit the plot in other software. Yes, I prefer it if I can create the plot in R and have it exactly the way I want it (without having to do any post-processing), but sometimes that may not be possible. Note that you can always add whatever you want to a plot created by the forest() function after it has been drawn. You can add text, lines, squares, polygons, whatever in any color you desire (e.g., with the text(), segments(), points(), polygon() functions). So, you could also just plot over the squares with: points(yi, 4:1, pch=15, col=red) To get rid of the black squares that are drawn by the forest function, add psize=0 as an argument in forest() (this will make the size of squares equal to 0, so essentially, they are invisible). If you want to make the size of the points inversely proportional to some function of the precision of the estimates, use points() together with the cex argument. For example: wi- 1/sqrt(vi) psize- wi/sum(wi) psize- (psize - min(psize)) / (max(psize) - min(psize)) psize- (psize * 1.0) + 0.5 points(yi, 4:1, pch=15, col=red, cex=psize) Best, Wolfgang -Original Message- From: Paola Tellaroli [mailto:[hidden email]http://user/SendEmail.jtp?type=nodenode=3768683i=0] Sent: Thursday, August 25, 2011 10:57 To: Viechtbauer Wolfgang (STAT) Cc: [hidden email]http://user/SendEmail.jtp?type=nodenode=3768683i=1; Bernd Weiss Subject: Re: [R] Change color in forest.rma (metafor) Thank you for your attention and help! In this way I get the diamond coloured, but actually I would have the squares representing the values of the individual studies coloured. Is it somehow possible? Paola 2011/8/24 Viechtbauer Wolfgang (STAT) [hidden email]http://user/SendEmail.jtp?type=nodenode=3768683i=2 Thank you, Bernd, for looking into this. Yes, at the moment, the color of the summary estimate for models without moderators is hard-coded (as black). I didn't think people may want to change that. I guess I was wrong =) A dirty solution for the moment is to add: addpoly(dfs, efac=6, row=-1, col=red, border=red, annotate=F, mlab=) after the call to forest(). You will get a warning message (since the border argument gets passed to the text() function inside addpoly() and that's not a par for text), but you can just ignore that. Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Maastricht University, P.O. Box 616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com -Original Message- From: Bernd Weiss [mailto:[hidden email]http://user/SendEmail.jtp?type=nodenode=3768683i=3] Sent: Wednesday, August 24, 2011 16:22 To: Paola Tellaroli Cc: [hidden email]http://user/SendEmail.jtp?type=nodenode=3768683i=4; [hidden email]http://user/SendEmail.jtp?type=nodenode=3768683i=5 Subject: Re: [R] Change color in forest.rma (metafor) Am 24.08.2011 07:50, schrieb Paola Tellaroli: My script is the following: library(metafor) yi-c(-0.1, 0.2, 0.3, 0.4) sei-c(0.4, 0.2, 0.6, 0.1) vi-sei^2 studi-c(A, B, C, D) eventi.c-c(10, 5, 7, 6)
Re: [R] integration
On 26.08.2011 20:27, . wrote: Hi Ravi, are you saying to apply the idea of a trapezoidal method again, because I was expecting the integrate() already do it for me. Is not the case? I am also dealing with troubles related to integrate. Just to say, I tried to figure out the problem in Mathematica and it gives me the expected/correct solution. I am integrating a function with shape like a exp(x), x0. The value of the function get lower when x is big but integrate return zero. If some one can give a suggestion, it will be very appreciated. -- View this message in context: http://r.789695.n4.nabble.com/integration-tp843252p3771660.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. So you never read the posting guide, ., did you? Please do so! Please specify reproducible examples! Please quote the original messages from the thread you are replying to. Note this is a mailing list you are obviously misusing via Nabble. If you want to contact Ravi, write also to Ravi and not only to the mailing list R-help! Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Optim function with multivariate inputs
On 25.08.2011 19:02, Noah Silverman wrote: Hi, I have function that I want to optimize. Am playing with the optim() function in R Two issues: 1) I can't seem to get it to work with a function that takes multiple inputs. Dummy Example: myFunc- function(A,B,D,D){ A really dummy example, since you must not have to equally named arguments in a function definition. # Do stuff return E } myFunc(1,2,3,4) [1] 12 # works fine from command line optim( par=c(1,2,3,4), fn=myFunc) Error in A+B : 'B' is missing Make it one argument, e.g. by a wrapper: wrapper - function(x) myFunc(A=x[1], B=x[2], ) 2) For SOME of the inputs, I want to fix the step size to integers. For another input, I would also like to limit the range of possible values for each input If you want box constrains, see the L-BFGS-B method in optim(). You cannot fix the step size to integers (except doing naste tricks like rounding) in optim(). For these things, take a look into the Optimization Task View on CRAN which lists packages for such tasks. The help file in R isn't very clear on either of the above issues. What is not clear? It mentions box constrains and it does not mention how to fix the step sizes to integers. Do you expect that help pages explain what features the functions do not have? Uwe Ligges Any suggestions? Thanks! -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095 [[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] Error: package 'lsei' is not installed for 'arch=i386'
On 27.08.2011 15:51, MK wrote: Hi guys, I am having problem loading a package that I have installed. I have searched some old thread but they were no help in terms of solving the problem. I uninstalled every possible component of R and installed R 2.13 May we assume R-2.13.1 is meant here? (there never was a R-2.13 release) and followed the R-faqs installation steps. Then I installed the package (lsei) from local zip file Further on, may we assume this is Windows? (unstated) which was installed successfully but can not be loaded and returns the error message as titled. The zip file can be downloaded below, it used to work fine on my old version of R (I think it was 2.9). http://www.stat.auckland.ac.nz/~yongwang/ I've check .libPaths() as some suggested and remove the copy in the first directory but that was the only copy that I have on the machine. Can someone give me a direction on how I can solve this problem? Don't use the Windows binary package but install the package from sources, two reasons: 1. Since R-2.10.x, R has a new help system. Binary packages prepared for R 2.10.0 cannot work with the new help system. 2. Since R-2.12.0, the location of compiled code changed. Hence binary packages prepared for R 2.12.0 that include compiled code cannot work with recent versions of R. Uwe Ligges Thanks in advance. MK R version 2.13.1 (2011-07-08) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(lsei) Error in library(lsei) : there is no package called 'lsei' utils:::menuInstallLocal() package 'lsei' successfully unpacked and MD5 sums checked library(lsei) Error: package 'lsei' is not installed for 'arch=i386' .libPaths() [1] C:/Users/user/R/win-library/2.13C:/Program Files/R/R-2.13.1/library -- View this message in context: http://r.789695.n4.nabble.com/Error-package-lsei-is-not-installed-for-arch-i386-tp3773012p3773012.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] read.table: deciding automatically between two colClasses values
Hi Josh, thanks, that worked! For the record, here is a function to determine the number of strings, space-separated, in the first line of a file: # Removes leading and trailing whitespaces from string x: trim = function(x) gsub(^\\s+|\\s+$, , x) # The number of strings in the first line in the file with name f: lengthfirstline = function(f) { length(unlist(strsplit(trim(readLines(f,1)), ))) } Oliver On Sun, Aug 28, 2011 at 07:23:07AM -0700, Joshua Wiley wrote: Hi Oliver, Look at ?readLines I imagine something like: tmp - readLines(filename, n = 1L) (do stuff with the first line to decide) IntN - 6 (or 4) NumN - 8 (or whatever) E - read.table(file = filename, header = TRUE, colClasses = c(rep(integer, IntN), numeric, integer, rep(numeric, NumN)), ...) Cheers, Josh On Sun, Aug 28, 2011 at 7:13 AM, Oliver Kullmann o.kullm...@swansea.ac.uk wrote: Hello, I have a function for reading a data-frame from a file, which contains E = read.table(file = filename, header = T, colClasses = c(rep(integer,6),numeric,integer,rep(numeric,8)), ...) Now a small variation arose, where colClasses = c(rep(integer,4),numeric,integer,rep(numeric,8)) needed to be used (so just a small change). I want to have it convenient for the user, so no user intervention shall be needed, but the function should choose between the two different values 4 and 6 here according to the header-line. Now this seems to be a problem: I found only count.fields, which however is not able just to read the first line. Reading the whole file (just to read the first line) is awkward, and also these files typically have millions of lines. The only possibility to influence count.fields seems via skip, but this I could only use to skip to the last line, which reads the file nevertheless, and I also don't know the number of lines in the file. Perhaps one could catch an error, when the first invocation of read.table fails, and try the second one. However tryCatch doesn't seem to make it simple to write something like E = try(expr1 otherwise expr2) (if expr1 fails, evaluate expr2 instead) ? Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] -log10 of 0
Dear R users: Sorry for this simple question: I am writing a function where I would need to pickup p values and make -log10 of it. The p values are from an anova output and sometime it can yield me 0. -log10 (0) [1] Inf I can not replace Inf with 0, which not case here. This is restricting me to go further in the function and out me the error. You help is highly appreciated. Thanks; -- Ram H [[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] Time Series data with data every half hour
On 26.08.2011 17:43, Simmons, Ryan wrote: I am working with data from the USGS with data every 30 minutes from 4/27/2011 to 8/25/2011. I am having trouble with setting the frequency. My R script is below: shavers=read.csv(shavers.csv) names(shavers) [1] agency_cdsite_no datetime tz_cdTemp [6] X04_00010_cd EC25 X05_00095_cd DO X06_00300_cd [11] pH X07_00400_cd as.POSIXct(shavers[1,3]) [1] 2011-04-27 EDT as.POSIXct(shavers[nrow(shavers),3]) [1] 2011-08-25 23:00:00 EDT temp=ts(shavers[,5],as.POSIXct(shavers[1,3]),frequency=48) Error in attr(data, tsp)- c(start, end, frequency) : invalid time series parameters specified I have also used xts: plot(temp) library(xts) temp=xts(shavers[,5],order.by=as.POSIXct(shavers[,3]),frequency=48) stl(temp,s.window='periodic') Error in stl(temp, s.window = periodic) : series is not periodic or has less than two periods The data has very clear daily periods. ... but you failed to tell this to the R functions correctly? How can I configure my time series to analyze this? We do not know, since we do see a reproducible example you have been asked to provide in the posting guide. Uwe Ligges Thank you very much. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Mixture of Regressions
I think that it should be possible to do this with the flexmix package. Christian On Fri, 26 Aug 2011, Andra Isan wrote: Dear All, I have two hidden classes for my data set that I would like to learn them based on the Mixture of Binomial regression model. I was wondering if there is any package that I can use for that purpose. Has any one tried any package for the Mixture models? Thanks a lot, Andra __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] -log10 of 0
On Aug 28, 2011, at 11:37 AM, Ram H. Sharma wrote: Dear R users: Sorry for this simple question: I am writing a function where I would need to pickup p values and make -log10 of it. The p values are from an anova output and sometime it can yield me 0. -log10 (0) [1] Inf I can not replace Inf with 0, which not case here. Well you could, but if you did, you would be shooting yourself in the foot. This is restricting me to go further in the function and out me the error. You help is highly appreciated. I would think that one would be better served , not by trying to redefine the log of small numbers, but rather by first putting a lowering bound on the p-values. pvec.trimmed - pmax(pvec, 0.001) min(log10(pvec.trimmed)) # now would be -7 The alternative that you suggest would be putting all of the p-values of 0 in the same locations as the p-values of 1 after log transformation. That cannot be a wise idea. Rather like redefining pi to be 3.14. -- 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] -log10 of 0
On 28-Aug-11 15:37:06, Ram H. Sharma wrote: Dear R users: Sorry for this simple question: I am writing a function where I would need to pickup p values and make -log10 of it. The p values are from an anova output and sometime it can yield me 0. -log10 (0) [1] Inf I can not replace Inf with 0, which not case here. This is restricting me to go further in the function and out me the error. You help is highly appreciated. Thanks; -- Ram H You cannot do anything about -log10(0) except to accept Inf. However, since log10() switches from a numeric answer to Inf between 1/(10^308)) and 1/(10^309), one possibility for reporting such a result is to report 308): -log10(1/(10^307)) # [1] 307 -log10(1/(10^308)) # [1] 308 -log10(1/(10^309)) # [1] Inf Note that the above forces R to compute the number before applying log10() to it. You can get a bit further with: -log10(1e-322) # [1] 322.0052 -log10(1e-323) # [1] 323.0052 -log10(1e-324) # [1] Inf -log10(1e-325) # [1] Inf which may have something to do with R parsing the expression before applying log10() to it (I don;t know). However, since the p-value returned from an ANOVA will be a number rather than an expression, the first set of results is probably more relevant to your case. Hoping this helps, Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 28-Aug-11 Time: 17:12:34 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I get a weighted frequency table?
Hello, I have to run a set of crosstabulations to which I need to apply some weights. I am currently doing an unweighted version of such crosstabs using table(x,y). I am used with SPSS to create a weighting variable and to use WEIGHT BY VAR before running the CTABLES, is there a similar procedure in R? Thanks, Luca Mr. Luca Meyer www.lucameyer.com R version 2.13.1 (2011-07-08) Mac OS X 10.6.8 [[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 do I get a weighted frequency table?
*Luca, * you may use survey package. You have to declare the design with design function and than you can you svytotal, svyby, svymean functions to do your tabulations. Regards, Leandro Atenciosamente, Leandro Marino http://www.leandromarino.com.br (Fotógrafo) http://est.leandromarino.com.br/Blog (Estatístico) Cel.: + 55 21 9845-7707 Cel.: + 55 21 8777-7907 2011/8/28 Luca Meyer lucam1...@gmail.com Hello, I have to run a set of crosstabulations to which I need to apply some weights. I am currently doing an unweighted version of such crosstabs using table(x,y). I am used with SPSS to create a weighting variable and to use WEIGHT BY VAR before running the CTABLES, is there a similar procedure in R? Thanks, Luca Mr. Luca Meyer www.lucameyer.com R version 2.13.1 (2011-07-08) Mac OS X 10.6.8 [[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] comparing two unequal matrices without for loop?
Dear folks, I would like to compare two unequal matrices. At the moment I realize this with two for loop and an if function but that's definitely too slow :(... Here is my code: for (i in 1:length(all_expressed_genes[,1])) { for (j in 1:length(kegg_gene_pVal[,1])) { if (all_expressed_genes[j,1] == kegg_gene_pVal[i,1]) { kegg_gene_pVal[j,4] = all_expressed_genes[i,6] } } } Are there any faster solutions for that easy code? And why is R so dramatically slow when using for, while or other loop functions? Thanks in advance, Paul - eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 10.0.1392 / Virendatenbank: 1520/3863 - Ausgabedatum: 28.08.2011 [[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] Trying to extract probabilities in CARET (caret) package with a glmStepAIC model
Can you provide a reproducible example and the results of sessionInfo()? What are the levels of your classes? On Sat, Aug 27, 2011 at 10:43 PM, Jon Toledo tintin...@hotmail.com wrote: Dear developers, I have jutst started working with caret and all the nice features it offers. But I just encountered a problem: I am working with a dataset that include 4 predictor variables in Descr and a two-category outcome in Categ (codified as a factor). Everything was working fine I got the results, confussion matrix etc. BUT for obtaining the AUC and predicted probabilities I had to add classProbs = TRUE, in the trainControl. Thereafter everytime I run train I get this message: undefined columns selected I copy the syntax: fitControl - trainControl(method = cv, number = 10, classProbs = TRUE,returnResamp = all, verboseIter = FALSE) glmFit - train(Descr, Categ, method = glmStepAIC,tuneLength = 4,trControl = fitControl) Thank you. Best regards, Jon Toledo, MD Postdoctoral fellow University of Pennsylvania School of Medicine Center for Neurodegenerative Disease Research 3600 Spruce Street 3rd Floor Maloney Building Philadelphia, Pa 19104 [[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. -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] -log10 of 0
Thank you Ted and David for prompt reply. I can accept Inf but can not use for plotting, which I intend to do. May be I can add 1/(10^308), so that if something comes to 0 will be in -log10 scale be 308. Ram H On Sun, Aug 28, 2011 at 12:12 PM, Ted Harding ted.hard...@wlandres.netwrote: On 28-Aug-11 15:37:06, Ram H. Sharma wrote: Dear R users: Sorry for this simple question: I am writing a function where I would need to pickup p values and make -log10 of it. The p values are from an anova output and sometime it can yield me 0. -log10 (0) [1] Inf I can not replace Inf with 0, which not case here. This is restricting me to go further in the function and out me the error. You help is highly appreciated. Thanks; -- Ram H You cannot do anything about -log10(0) except to accept Inf. However, since log10() switches from a numeric answer to Inf between 1/(10^308)) and 1/(10^309), one possibility for reporting such a result is to report 308): -log10(1/(10^307)) # [1] 307 -log10(1/(10^308)) # [1] 308 -log10(1/(10^309)) # [1] Inf Note that the above forces R to compute the number before applying log10() to it. You can get a bit further with: -log10(1e-322) # [1] 322.0052 -log10(1e-323) # [1] 323.0052 -log10(1e-324) # [1] Inf -log10(1e-325) # [1] Inf which may have something to do with R parsing the expression before applying log10() to it (I don;t know). However, since the p-value returned from an ANOVA will be a number rather than an expression, the first set of results is probably more relevant to your case. Hoping this helps, Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 28-Aug-11 Time: 17:12:34 -- XFMail -- -- Ram H [[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 download Yahoo Quote?
Hi Michael: I have simplified the code only to download the sp500 index. How to correct this simple codes. -- View this message in context: http://r.789695.n4.nabble.com/How-download-Yahoo-Quote-tp3769563p3774672.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] -log10 of 0
On Aug 28, 2011, at 18:12 , (Ted Harding) wrote: -log10(1/(10^307)) # [1] 307 -log10(1/(10^308)) # [1] 308 -log10(1/(10^309)) # [1] Inf Note that the above forces R to compute the number before applying log10() to it. You can get a bit further with: -log10(1e-322) # [1] 322.0052 -log10(1e-323) # [1] 323.0052 -log10(1e-324) # [1] Inf -log10(1e-325) # [1] Inf which may have something to do with R parsing the expression before applying log10() to it (I don;t know). That's a red herring: log10(10^-323) [1] -323.0052 log10(1e309) [1] Inf It's just that the situation is not quite symmetric between large and small values. This is because R (and the underlying FP support) allows denormalized numbers. Quick and somewhat imprecise FP tutorial (if you care about the very final bits of the FP double, I'm sure Google gets you there soon enough): Floating numbers are usually stored as sign*0.1...*2^y, where the dots represent 52 more binary digits and y is between -1023 and +1023. I.e. the first digit of the mantissa is a 1. However, in a denormalized value, the mantissa can be 0.0...01. allowing a somewhat more graceful transition to zero at the expense of relative accuracy. This effectively buys you the 15 extra orders of magnitude, but only for small numbers. Notice that the granularity of these very small numbers is quite coarse: 1e-323 - 1.5e-323 [1] -4.940656e-324 1e-323 - 1.4e-323 [1] -4.940656e-324 1e-323 - 1.3e-323 [1] -4.940656e-324 1e-323 - 1.2e-323 [1] 0 -- 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 Døden skal tape! --- Nordahl Grieg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 download Yahoo Quote?
I have simplified the code only to download the sp500 index. Perhaps you have, but you haven't provided any of that simplified code so I'm a little skeptical. I do have to say though, if you've managed to do it more efficiently than the 12 characters in getSymbols() you are a far better coder than I. Michael On Sun, Aug 28, 2011 at 12:46 PM, Yumin zpx...@gmail.com wrote: Hi Michael: I have simplified the code only to download the sp500 index. How to correct this simple codes. -- View this message in context: http://r.789695.n4.nabble.com/How-download-Yahoo-Quote-tp3769563p3774672.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] comparing two unequal matrices without for loop?
On Aug 28, 2011, at 1:20 PM, Paul Hammer wrote: Dear folks, I would like to compare two unequal matrices. Unequal is hardly an adequate data description. At the moment I realize this with two for loop and an if function but that's definitely too slow :(... Here is my code: for (i in 1:length(all_expressed_genes[,1])) { for (j in 1:length(kegg_gene_pVal[,1])) { if (all_expressed_genes[j,1] == kegg_gene_pVal[i,1]) { kegg_gene_pVal[j,4] = all_expressed_genes[i,6] } } } Are there any faster solutions for that easy code? I'm trying to figure out what this is supposed to be doing. You are making N^2 comparisons and transferring results from one vector of length N to another vector of length N. Is this really what the (non- existent) problem definition would have told us to do if you had provided a problem definition? It appears there would be a great possibility of overwriting earlier operations. And it appears to be doing N^2-N unnecessary operations as well. And why is R so dramatically slow when using for, while or other loop functions? Blaming the tool is generally a risky idea. Axes can be used effectively or ineffectively. I'm guessing inadequate operator training and/or confused problem specification. *-* 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] comparing two unequal matrices without for loop?
Look into merge() or, if you want to work at a lower level, match(). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Sunday, August 28, 2011 11:07 AM To: Paul Hammer Cc: r-help@r-project.org Subject: Re: [R] comparing two unequal matrices without for loop? On Aug 28, 2011, at 1:20 PM, Paul Hammer wrote: Dear folks, I would like to compare two unequal matrices. Unequal is hardly an adequate data description. At the moment I realize this with two for loop and an if function but that's definitely too slow :(... Here is my code: for (i in 1:length(all_expressed_genes[,1])) { for (j in 1:length(kegg_gene_pVal[,1])) { if (all_expressed_genes[j,1] == kegg_gene_pVal[i,1]) { kegg_gene_pVal[j,4] = all_expressed_genes[i,6] } } } Are there any faster solutions for that easy code? I'm trying to figure out what this is supposed to be doing. You are making N^2 comparisons and transferring results from one vector of length N to another vector of length N. Is this really what the (non- existent) problem definition would have told us to do if you had provided a problem definition? It appears there would be a great possibility of overwriting earlier operations. And it appears to be doing N^2-N unnecessary operations as well. And why is R so dramatically slow when using for, while or other loop functions? Blaming the tool is generally a risky idea. Axes can be used effectively or ineffectively. I'm guessing inadequate operator training and/or confused problem specification. *-* 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Comparing skewness of two distributions
On Fri, Aug 26, 2011 at 10:20 AM, Benjamin Polidore polid...@gmail.com wrote: I have two distributions. Is there a statistical approach to determine if the skew of distribution 1 is similar to the skew of distribution 2? On Aug 26, 2011, at 10:07 PM, Joshua Wiley wrote: par(mfrow = c(2, 1)) plot(density(rnorm(100)^2)) plot(density(rnorm(100)^2)) The density graph will show what your density looks like. If you need an empirical test of their similarity, Jorge Ivan Velez kindly wrote this in response to my similar question a month ago... # kurtosis kurd - function(x, y, B = 1000){ kx - replicate(B, kurtosi(sample(x, replace = TRUE))) ky - replicate(B, kurtosi(sample(y, replace = TRUE))) kx - ky } # skew skewd - function(x, y, B = 1000){ sx - replicate(B, skew(sample(x, replace = TRUE))) sy - replicate(B, skew(sample(y, replace = TRUE))) sx - sy } # --- # example # --- # data x - rnorm(100, 25, 4) y - rexp(50, 1/25) # kurtosis distribution require(psych) res1 - kurd(x, y, B = 1) mean(res1 0) hist(res1, breaks = 50) # skew distribution res2 - skewd(x, y, B = 1) mean(res2 0) hist(res2, breaks = 50) [[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] cspade error
Hi, I'm using the cspade function from the arulesSequences package on linux and keep getting the error: Error in makebin(data, file) : 'sid' invalid any information on how to solve this would be much appreciated. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/cspade-error-tp3774834p3774834.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] Function won't permanently assign values to a vector
I'm somewhat new to R, but I've had a lot of experience in Java. I'm working on a function that takes data from a data frame, does some math and assigns the values to a vector. Pretty simple. I plan to merge the vector with the data frame when I'm done. The vector is called offense1 (there will eventually be 2). I declared it on its own, outside of the function. Right now its values are the same as its indices: 1, 2, 3... Then I plugged it into the function: getOffense1(1:20, offense1). 1:20 is the range of offense1 that will be worked upon. Everything about the function works: It generates the correct values and plugs them into the vector. I checked with print statements. The problem is that when the function ends, offense1 is unchanged. All the values it takes on are temporary. I thought it might be because the assignment (offense1[v] - ___) happens inside a for loop, but a call to print( offense1[1:20] ) just after the loop is finished turns out the right values. All that seems to matter is whether it's inside the function or not. How can I assign values permanently to offense1? -- View this message in context: http://r.789695.n4.nabble.com/Function-won-t-permanently-assign-values-to-a-vector-tp3774850p3774850.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] Trying to extract probabilities in CARET (caret) package with a glmStepAIC model
I corrected some of my syntax and changed the the glmStepAIC for glm and ti worked. I tried my command lines with the mdrr dataset (after doing the first cleaning steps as referred in the manual), the only difference is that I only took first two columns because it took too much time with one variable and I got the same resutls: undefined columns selected. Here are the command lines: fitControlAUC - trainControl(method = cv, number = 10, classProbs = TRUE, summaryFunction = twoClassSummary, returnResamp = all, verboseIter = FALSE) glmROCLum1 - train(trainDescr[,(1:4)], trainMDRR, method = glmStepAIC, tuneLength = 4, metric = ROC, trControl = fitControlAUC) So I used glmStepAIC to find the right model and the to obtain the ROC results I used the glm method using the variables select by glmStepAIC. Thank you very much for your package help and interest. Best regards, J Toledo Here is my previous session Info R version 2.13.0 (2011-04-13)Platform: i386-pc-mingw32/i386 (32-bit) locale:[1] LC_COLLATE=Spanish_United States.1252 LC_CTYPE=Spanish_United States.1252 [3] LC_MONETARY=Spanish_United States.1252 LC_NUMERIC=C [5] LC_TIME=Spanish_United States.1252 attached base packages:[1] splines tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] e1071_1.5-26class_7.3-3 caret_4.98 cluster_1.14.0 reshape_0.8.4 plyr_1.5.2 [7] lattice_0.19-26 Rcmdr_1.6-4 car_2.0-10 foreign_0.8-44 survival_2.36-9 nnet_7.3-1 [13] MASS_7.3-13 loaded via a namespace (and not attached):[1] grid_2.13.0 Date: Sun, 28 Aug 2011 13:23:24 -0400 Subject: Re: [R] Trying to extract probabilities in CARET (caret) package with a glmStepAIC model From: mxk...@gmail.com To: tintin...@hotmail.com CC: r-help@r-project.org Can you provide a reproducible example and the results of sessionInfo()? What are the levels of your classes? [[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] Function won't permanently assign values to a vector
Two things: It's just a guess as to what your problem is, but functions in R don't usually act on the object that is passed to them, but rather a copy thereof: if you want to keep the values calculated within the function, that's usually done with an assignment statement combined with the function call. E.g. squaring - function(x) {x^2} z = 1:5 squaring(z) z [1] 1 2 3 4 5 z = squaring(z) z [1] 1 4 9 16 25 More generally, please provide code as requested in the posting guide. Hope this helps, Michael Weylandt On Sun, Aug 28, 2011 at 2:39 PM, DimmestLemming nicoadams...@gmail.comwrote: I'm somewhat new to R, but I've had a lot of experience in Java. I'm working on a function that takes data from a data frame, does some math and assigns the values to a vector. Pretty simple. I plan to merge the vector with the data frame when I'm done. The vector is called offense1 (there will eventually be 2). I declared it on its own, outside of the function. Right now its values are the same as its indices: 1, 2, 3... Then I plugged it into the function: getOffense1(1:20, offense1). 1:20 is the range of offense1 that will be worked upon. Everything about the function works: It generates the correct values and plugs them into the vector. I checked with print statements. The problem is that when the function ends, offense1 is unchanged. All the values it takes on are temporary. I thought it might be because the assignment (offense1[v] - ___) happens inside a for loop, but a call to print( offense1[1:20] ) just after the loop is finished turns out the right values. All that seems to matter is whether it's inside the function or not. How can I assign values permanently to offense1? -- View this message in context: http://r.789695.n4.nabble.com/Function-won-t-permanently-assign-values-to-a-vector-tp3774850p3774850.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] Function won't permanently assign values to a vector
It will greatly help if you provide a self-contained example, as requested in the posting guide. Most of the times this will in fact lead to you figuring out your problem yourself, but if not it will greatly enhance your chances that we can help you in a meaningful, unambiguous way. Best, Daniel DimmestLemming wrote: I'm somewhat new to R, but I've had a lot of experience in Java. I'm working on a function that takes data from a data frame, does some math and assigns the values to a vector. Pretty simple. I plan to merge the vector with the data frame when I'm done. The vector is called offense1 (there will eventually be 2). I declared it on its own, outside of the function. Right now its values are the same as its indices: 1, 2, 3... Then I plugged it into the function: getOffense1(1:20, offense1). 1:20 is the range of offense1 that will be worked upon. Everything about the function works: It generates the correct values and plugs them into the vector. I checked with print statements. The problem is that when the function ends, offense1 is unchanged. All the values it takes on are temporary. I thought it might be because the assignment (offense1[v] - ___) happens inside a for loop, but a call to print( offense1[1:20] ) just after the loop is finished turns out the right values. All that seems to matter is whether it's inside the function or not. How can I assign values permanently to offense1? -- View this message in context: http://r.789695.n4.nabble.com/Function-won-t-permanently-assign-values-to-a-vector-tp3774850p3774946.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] cspade error
I have a vector with entries like 1,1,2,item1,item2 or 1,2,1,item1 that I save as file_name.txt and then is transformed into a transaction by calling: data_ex - read_baskets(file_name.txt, sep=,, info= c(eventID,sequenceID,SIZE)) as the first first three parts of the entry correspond to the eventID (my customer number), the sequenceID (1 means the first shop for that customer, 2 the second and so on) and the SIZE (the number of items). Then I create the inputs for the cspade function: p - as(list(support=0.8), SPparameter) q - as(list(verbose = TRUE, memsize=3000), SPcontrol) and finally I call cspade: cspade(data_ex, parameter = p, control = q, tmpdir = tempdir()) -- View this message in context: http://r.789695.n4.nabble.com/cspade-error-tp3774834p3774955.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] Error: package 'lsei' is not installed for 'arch=i386'
Uwe Ligges-3 wrote: On 27.08.2011 15:51, MK wrote: Hi guys, I am having problem loading a package that I have installed. I have searched some old thread but they were no help in terms of solving the problem. I uninstalled every possible component of R and installed R 2.13 May we assume R-2.13.1 is meant here? (there never was a R-2.13 release) and followed the R-faqs installation steps. Then I installed the package (lsei) from local zip file Further on, may we assume this is Windows? (unstated) which was installed successfully but can not be loaded and returns the error message as titled. The zip file can be downloaded below, it used to work fine on my old version of R (I think it was 2.9). http://www.stat.auckland.ac.nz/~yongwang/ I've check .libPaths() as some suggested and remove the copy in the first directory but that was the only copy that I have on the machine. Can someone give me a direction on how I can solve this problem? Don't use the Windows binary package but install the package from sources, two reasons: 1. Since R-2.10.x, R has a new help system. Binary packages prepared for R 2.10.0 cannot work with the new help system. 2. Since R-2.12.0, the location of compiled code changed. Hence binary packages prepared for R 2.12.0 that include compiled code cannot work with recent versions of R. Uwe Ligges I have run R CMD check on the source package obtained from the link provided by the OP. The sources need repair work. There are unexpected } in the documentation. There are undocumented functions at user level (because of no NAMESPACE?) The Fortran source contains trailing spaces on many (maybe all) lines causing gfortran warnings for lines truncated at column 72 (harmless but shouldn't happen) Berend -- View this message in context: http://r.789695.n4.nabble.com/Error-package-lsei-is-not-installed-for-arch-i386-tp3773012p3774960.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] converting matrix in array
Hi everyone, have a small problem trying to converting a dataset in matrix form to an array. Specifically: data include 3D measurement -x,y,z of 59 points in 36 objects. They are stored as a matrix (x) of 2124 rows and 3 columns. What I want to do is to extract each subject's dataset using an array (b). Accordingly, I tried the following command: b-array(a,c(59,3,36)). The problem is that the resulting array for some strange reason change the order of the original data. Specifically, I noticed that, for example, in the first subject, the x y z values of the first point are the x values of the first 3 subjects. Did I perhaps missed something? Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/converting-matrix-in-array-tp3775025p3775025.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting matrix in array
On Aug 28, 2011, at 5:09 PM, marco wrote: Hi everyone, have a small problem trying to converting a dataset in matrix form to an array. Specifically: data include 3D measurement -x,y,z of 59 points in 36 objects. They are stored as a matrix (x) of 2124 rows and 3 columns. What I want to do is to extract each subject's dataset using an array (b). Accordingly, I tried the following command: b-array(a,c(59,3,36)). The problem is that the resulting array for some strange reason change the order of the original data. Not for a strange reason. The 59 elements in b in column-1 would be the same in both , but you don't seem to realize that the 60th through the 118th elements in your original matrix were also all in the x- column. You have now effectively moved those values to what you were thinking to use as the y-column. Specifically, I noticed that, for example, in the first subject, the x y z values of the first point are the x values of the first 3 subjects. You should have kept the last dimension the same and redimension the object/points indexing by factoring the 2124 rows into what will become columns and row and leave the xyz coordinates at the end. I think that redimensioning as b-array(a,c(59, 36, 3)) would have re- folded it sensiblyly. So the b[n,m,] call would retrieve xyz- coordinates from the n-th point of the m-th object. Did I perhaps missed something? Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/converting-matrix-in-array-tp3775025p3775025.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. 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] converting matrix in array
It helps to consider a small self-containd example where the correct answer is obvious. Does the following look like your input and desired output? a - rbind(c(obj1-ptA-x, obj1-ptA-y, obj1-ptA-z), +c(obj1-ptB-x, obj1-ptB-y, obj1-ptB-z), +c(obj2-ptA-x, obj2-ptA-y, obj2-ptA-z), +c(obj2-ptB-x, obj2-ptB-y, obj2-ptB-z)) a [,1] [,2] [,3] [1,] obj1-ptA-x obj1-ptA-y obj1-ptA-z [2,] obj1-ptB-x obj1-ptB-y obj1-ptB-z [3,] obj2-ptA-x obj2-ptA-y obj2-ptA-z [4,] obj2-ptB-x obj2-ptB-y obj2-ptB-z aperm(array(a, c(2, 2, 3)), c(1,3,2)) , , 1 [,1] [,2] [,3] [1,] obj1-ptA-x obj1-ptA-y obj1-ptA-z [2,] obj1-ptB-x obj1-ptB-y obj1-ptB-z , , 2 [,1] [,2] [,3] [1,] obj2-ptA-x obj2-ptA-y obj2-ptA-z [2,] obj2-ptB-x obj2-ptB-y obj2-ptB-z Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of marco Sent: Sunday, August 28, 2011 2:10 PM To: r-help@r-project.org Subject: [R] converting matrix in array Hi everyone, have a small problem trying to converting a dataset in matrix form to an array. Specifically: data include 3D measurement -x,y,z of 59 points in 36 objects. They are stored as a matrix (x) of 2124 rows and 3 columns. What I want to do is to extract each subject's dataset using an array (b). Accordingly, I tried the following command: b-array(a,c(59,3,36)). The problem is that the resulting array for some strange reason change the order of the original data. Specifically, I noticed that, for example, in the first subject, the x y z values of the first point are the x values of the first 3 subjects. Did I perhaps missed something? Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/converting-matrix-in-array- tp3775025p3775025.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] RODBC: sqlUpdate doesn't handle properly POSIXct field?
Thanks a bunch, it was driving me nuts. My experience would seem to confirm yours. Thanks to your post, I fixed a database update that was crashing my R session. I changed the data column that I was posting from a POSIXct to a Date, and now the data goes in. That works fine for me since my dataset is daily. -- View this message in context: http://r.789695.n4.nabble.com/RODBC-sqlUpdate-doesn-t-handle-properly-POSIXct-field-tp3725857p3775164.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] R question: generating data using MASS
Hi, all! I'm new to R but need to use it to solve a little problem I'm having with a paper I'm writing. The question has a few components and I'd appreciate guidance on any of them. 1. The most essential thing is that I need to generate some multivariate normal data on a restricted integer range (1 to 7). I know I can use MASS mvrnorm command to do this but have a couple questions about that: -I can make the simulated data but I don't know how to issue a command that restricts the generated data to be between a specific range (1 to 7), and integer-only. -Is there a way to specify a single desired correlation between all the variables (i.e., I want, say, five variables to all be correlated about .30 with each other), rather than input the entire covariance matrix as sigma? 2. I need to introduce missing data (NA) AFTER generating the data set, and I need it to be random and at a specific prevalence (say, 5%). Is there a simple way to take the initial data set and randomly replace 5% of values with NA missing values? Thanks, I appreciate any guidance folks can offer. :-) -- View this message in context: http://r.789695.n4.nabble.com/R-question-generating-data-using-MASS-tp3775093p3775093.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] parallel rbind
As I am sitting here waiting for some R scripts to run...I was wondering... is there any way to parallelize rbind in R? I wait for this call to complete frequently as I deal with large amounts of data. do.call(rbind, LIST) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] parallel rbind
What exactly do you mean by parallelize? What is wrong with the approach that you are using now? What is a large amount of data? Can you give some specifics on the problem you are trying to solve and why your present approach does not appear to be working? What are your expectations of a potential solution? On Sun, Aug 28, 2011 at 8:36 PM, Steven Bauer steven.ba...@gmail.com wrote: As I am sitting here waiting for some R scripts to run...I was wondering... is there any way to parallelize rbind in R? I wait for this call to complete frequently as I deal with large amounts of data. do.call(rbind, LIST) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Help with levelplot color assignment in lattice
Hi If you change the NA to a value either below or above the range of values you can then use it. Below is something that is cobbled together from some code I have. The datacols argument may be necessary if you want to do something fancy like I was doing I used my own colours to see if all was working - I frequently want colours that standout when placed in a grid rather than graduated shades. data$level[is.na(data$level)] - 10 datacols - with(data, level.colors(level, at = c(-0.5,1:11), col.regions = TRUE, colors = FALSE)) levelplot(level~ x* y, data = data, #colors = datacols, as.table = TRUE, at= c(0:10), col.regions = c(#FF,#00FF00,#FF,#FFA54F,#00,#FF00FF,#C0,#00B414,#FFD18F,#00), colorkey = list(at = c(0:9,10), labels= c(as.character(c(0:9)),dead)), xlab=x, ylab=y, strip = strip.custom(factor.levels = c(date 3))) Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email: home mac...@northnet.com.au At 23:15 28/08/2011, you wrote: Dear R users, I'm currently trying to make level plots of a longitudinal study of the spatio-temporal spread of a plant disease in a field, but the results of the color key assignment isn't what I expect. Here's more info. I recorded the level of a disease on an ordinal scale from 0 (no disease) to 9 (dead plant) on a grid that has 9 rows and 14 columns. The disease level on each plant was recorded on a weekly basis, and I what I need is to make a levelplot from each weekly snapshot, and of course the color levels need to be the same to compare images, and ultimately turn this in an animation to visualize the spread of the disease in time and space. In the following code, what I get from levelplot in lattice is a color scale that is not centered, and not correct (I want white for level=0, red for level=9, and yellow shades for intermediate levels). Is there a way to make it look right ? # Example data set from an intermediate snapshot. Note that at the maximal level recorded in this one is 8, but I still want the color key to go up to 9 for comparison with later plots data - data.frame(x=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14),y=rev(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9)),level=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, NA, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 1, 1, 1, 1, 1, 1)) library(lattice) library(grDevices) # For the color palette colpal - colorRampPalette(c(white,yellow,red)) colseq - seq(0,9,by=1) levelplot(level~ x* y, data = data, as.table = TRUE, at = colseq, region = TRUE, col.regions = colpal(10), colorkey = list(at = colseq, labels=list(at=colseq)), xlab=x, ylab=y, strip = strip.custom(factor.levels = c(date 3))) As you should see, instead of having the level 0 polygon in white, and most polygons in the first shade of yellow (level 1), most of them ar white. As an extra, I would like to have the NA data appear as black, but I know I can use lrect do to it. The attached image is from the graph I can obtain from a custom fonction calling the regular plot() and assigning colors to polygons, and color.legend() from package plotrix to generate the color key. It gives me the right kind of color key and colors assignment to polygons (and note how the color key lebaels are centered vertically with regards to the polygons), but the plot() is not as easily customizable as I'd like. I hope you can help me figure it out with lattice. http://r.789695.n4.nabble.com/file/n3774374/levelplot.jpg -- View this message in context: http://r.789695.n4.nabble.com/Help-with-levelplot-color-assignment-in-lattice-tp3774374p3774374.html Sent from the R help mailing list archive at Nabble.com.
Re: [R] parallel rbind
If you know much about what the elements of LIST look like you can speed things up by not making R figure out what you already know. E.g., if you know that LIST consists of p numeric vectors, all of the same length, n, then the following might be faster matrix(unlist(LIST, use.names=FALSE), nrow=n) If you are worried about row or column names then you can add that information to the call to matrix(). (The above will also work if LIST contains some matrix elements, as long as they all have n rows.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Bauer Sent: Sunday, August 28, 2011 5:36 PM To: r-help@r-project.org Subject: [R] parallel rbind As I am sitting here waiting for some R scripts to run...I was wondering... is there any way to parallelize rbind in R? I wait for this call to complete frequently as I deal with large amounts of data. do.call(rbind, LIST) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] parallel rbind
Oops, I mixed up rbind and cbind. If LIST consists of n numeric vectors, each of length p, try matrix(unlilst(LIST, use.names=FALSE), nrow=n, byrow=TRUE) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: William Dunlap Sent: Sunday, August 28, 2011 6:57 PM To: 'Steven Bauer'; r-help@r-project.org Subject: RE: [R] parallel rbind If you know much about what the elements of LIST look like you can speed things up by not making R figure out what you already know. E.g., if you know that LIST consists of p numeric vectors, all of the same length, n, then the following might be faster matrix(unlist(LIST, use.names=FALSE), nrow=n) If you are worried about row or column names then you can add that information to the call to matrix(). (The above will also work if LIST contains some matrix elements, as long as they all have n rows.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Bauer Sent: Sunday, August 28, 2011 5:36 PM To: r-help@r-project.org Subject: [R] parallel rbind As I am sitting here waiting for some R scripts to run...I was wondering... is there any way to parallelize rbind in R? I wait for this call to complete frequently as I deal with large amounts of data. do.call(rbind, LIST) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.