Re: [R] substituting level for NA in factor column
Hi r-help-boun...@r-project.org napsal dne 19.01.2011 00:03:10: On Jan 18, 2011, at 5:25 PM, kurt_h...@nps.gov wrote: Greetings I have a bunch of NAs in a column of categorical variables designating the size classes (e.g., smallest to largest: 1,2,3,4) of cave crickets. I'd like to substitute U (for unknown) for the NAs. Can anyone give me an idea how to do this? Thanks in advance. vect=factor(c(1,2,3,4,NA)) vect [1] 1234NA Levels: 1 2 3 4 levels(vect) - c(levels(vect), U) vect[is.na(vect)] - U vect [1] 1 2 3 4 U Levels: 1 2 3 4 U You can set also NA as an additional level through exclude=NULL option factor(vect, exclude=NULL) [1] 1234NA Levels: 1 2 3 4 NA Regards Petr -- David. Cheers Kurt *** Kurt Lewis Helf, Ph.D. Ecologist EEO Counselor National Park Service Cumberland Piedmont Network P.O. Box 8 Mammoth Cave, KY 42259 Ph: 270-758-2163 Lab: 270-758-2151 Fax: 270-758-2609 Science, in constantly seeking real explanations, reveals the true majesty of our world in all its complexity. -Richard Dawkins The scientific tradition is distinguished from the pre-scientific tradition in having two layers. Like the latter it passes on its theories but it also passes on a critical attitude towards them. The theories are passed on not as dogmas but rather with the challenge to discuss them and improve upon them. -Karl Popper ...consider yourself a guest in the home of other creatures as significant as yourself. -Wayside at Wilderness Threshold in McKittrick Canyon, Guadalupe Mountains National Park, TX Cumberland Piedmont Network (CUPN) Homepage: http://tiny.cc/e7cdx CUPN Forest Pest Monitoring Website: http://bit.ly/9rhUZQ CUPN Cave Cricket Monitoring Website: http://tiny.cc/ntcql CUPN Cave Aquatic Biota Monitoring Website: http://tiny.cc/n2z1o __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Reshape
Hi: Here's a variation on Jim Holtman's solution - same packages. df - data.frame(V1 = rep(c('X1', 'X2'), each = 3), V2 = rep(c('Y1', 'Y2', 'Y3'), 2), Y1 = rep(1, 6), Y2 = rep(2, 6), Y3 = rep(3, 6)) dd - melt(df, id = c('V1', 'V2')) dcast(dd, V2 + variable ~ V1) # A little better... dcast(dd, V2 + variable ~ V1)[, -2] V2 X1 X2 1 Y1 1 1 2 Y1 2 2 3 Y1 3 3 4 Y2 1 1 5 Y2 2 2 6 Y2 3 3 7 Y3 1 1 8 Y3 2 2 9 Y3 3 3 HTH, Dennis On Tue, Jan 18, 2011 at 6:18 PM, pwilliam pwill...@uoregon.edu wrote: Hi - I'm up against a complicated reshape problem. I have data of the form X1,Y1,hr1,hr2,hr3 X1,Y2,hr1,hr2,hr3 X1,Y3,hr1,hr2,hr3 X2,Y1,hr1,hr2,hr3 X2,Y2,hr1,hr2,hr3 X2,Y3,hr1,hr2,hr3 where X and Y are factors and the hr(1,2,3) are values. I need it as ,X1, X2 Y1,hr1,hr1 Y1,hr2,hr2 Y1,hr3,hr3 Y2,hr1,hr1 Y2,hr2,hr2 Y2,hr3,hr3 .., Any hints? I've been at it for hours. p -- View this message in context: http://r.789695.n4.nabble.com/Reshape-tp3224455p3224455.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] Using subset to filter data table
tcc.new2 - droplevels(tcc.new) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Harrison Sent: 19 January 2011 12:24 To: r-help@r-project.org Subject: [R] Using subset to filter data table I am having difficulty understanding how I would constrain a data set by filtering out 'records' based on certain criteria. Using SQL I could query using 'select * from my.data where LithClass in ('sand', 'clay')' or some such. Using subset, there seem to be ghosts left behind (that is, all of the LithClass *.Labels* remain after subset) dput(tcc) structure(list(Density = c(1.84, 1.91, 2, NA, 1.95, 2.04, 2.11, 1.85, 1.97, 2, 2.27, NA, NA, 2.18, NA, NA, 1.9, 2.68, 2.69, NA, -- snip -- 1.45, 1.49, 2.11), LithClass = structure(c(6L, 6L, 5L, 6L, 7L, 7L, 6L, 6L, 5L, 5L, 5L, 2L, 3L, 2L, 3L, 7L, 7L, 4L, 4L, 2L, 7L, 3L, 2L, 2L, 3L, 7L, 2L, 2L, 3L, 2L, 6L, 5L, 5L, 5L, 6L, 6L, 7L, 2L, 3L, 7L, 7L, 7L, 7L, 2L, 7L, 7L, 2L, 7L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 7L, 3L, 2L, 2L, 3L, 2L, 7L, 3L, 5L, 6L, 6L, 6L, 3L, 6L, 3L, 7L, 2L, 3L, 3L, 3L, 7L, 3L, 2L, 2L, 7L, 5L, 5L, 5L, 5L, 5L, 5L, 3L, 2L, 3L, 3L, 3L, 7L, 7L, 2L, 6L, 6L, 6L, 7L, 7L, 7L, 1L, 2L, 2L, 7L, 7L, 2L, 7L, 7L, 7L, 3L, 3L, 2L, 5L, 5L), .Label = c(basalt, clay, coal, dolomite, limestone, marl, sand), class = factor)), .Names = c(Density, Depth, Porosity, Conductivity, LithClass), row.names = c(NA, 114L), class = data.frame) tcc.new = subset(tcc, LithClass %in% c('clay','sand','marl')) dput(tcc.new) structure(list(Density = c(1.84, 1.91, NA, 1.95, 2.04, 2.11, -- snip-- 1.63, 2.84, 1.93, 1.67, 2.22, 2.42, 1.84, 2.24, 2.38, 2.33, 1.45), LithClass = structure(c(6L, 6L, 6L, 7L, 7L, 6L, 6L, 2L, 2L, 7L, 7L, 2L, 7L, 2L, 2L, 7L, 2L, 2L, 2L, 6L, 6L, 6L, 7L, 2L, 7L, 7L, 7L, 7L, 2L, 7L, 7L, 2L, 7L, 6L, 7L, 2L, 2L, 2L, 7L, 6L, 6L, 6L, 6L, 7L, 2L, 7L, 2L, 2L, 7L, 2L, 7L, 7L, 2L, 6L, 6L, 6L, 7L, 7L, 7L, 2L, 2L, 7L, 7L, 2L, 7L, 7L, 7L, 2L), .Label = c(basalt, clay, coal, dolomite, limestone, marl, sand), class = factor)), .Names = c(Density, Depth, Porosity, Conductivity, LithClass), row.names = c(1L, 2L, 4L, 5L, 6L, 7L, 8L, 12L, 14L, 16L, 17L, 20L, 21L, 23L, 24L, 26L, 27L, 28L, 30L, 31L, 35L, 36L, 37L, 38L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 55L, 56L, 58L, 59L, 61L, 62L, 65L, 66L, 67L, 69L, 71L, 72L, 76L, 78L, 79L, 80L, 88L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 112L), class = data.frame) The data (in the structure) is removed, but the labels for all LithClass remain. If I then produce a boxplot or some other graphic where LithClass is involved, blank plots are produced for the deleted LithClass labels, which is not what I want. i.e.: with(tcc.new, boxplot(Conductivity~LithClass)) Here is the full data: 1 dput(tcc) structure(list(Density = c(1.84, 1.91, 2, NA, 1.95, 2.04, 2.11, 1.85, 1.97, 2, 2.27, NA, NA, 2.18, NA, NA, 1.9, 2.68, 2.69, NA, 2.41, 1.16, 1.92, 1.96, 0.87, NA, NA, NA, 1.4, NA, 1.83, 1.93, 2.14, 2.18, NA, 2.12, 2.05, NA, 1.53, 2.23, 2.2, NA, 2.42, 2.54, 2.48, 2.58, 1.91, 2.09, 1.85, 2.48, 2.34, 2.19, 2.23, 2.09, 2.57, 2.12, 1.88, 2.21, 2.06, 1.21, 2.08, 1.84, 1.71, 2.11, 1.9, 1.84, 1.97, 1.57, NA, NA, 1.92, 2.29, NA, 1.17, NA, NA, 1.77, 2.03, 2.27, 2.22, 1.84, 2.09, 1.94, 2.3, 2.59, NA, 1.52, 2.15, 1.19, NA, 1.14, 1.99, 1.94, 2.01, 2.02, 1.91, 2.45, 2.09, NA, NA, 2.14, 2.4, 2.47, 2.48, 2.49, 2.51, 2.49, 2.51, 2.5, 1.18, 1.23, 1.94, 2.04, 2.39), Depth = c(151, 198, 284, 480, 33.4, 75, 142, 186, 258, 420.6, 679.2, 884.1, 916, 943, 972, 998, 1064.4, 1076.7, 1125.6, 1176.5, 1225.6, 255.8, 272, 205.6, 319.3, 352.6, 666.1, 667.6, 918, 105, 156.5, 213, 305.1, 498, 591.75, 726, 765.4, 793.4, 829.1, 861, 896, 929, 957.9, 989.7, 1017, 1018, 96, 229, 355, 376, 456, 496, 515, 537, 557, 627, 512, 551, 615, 381.8, 585.3, 587.2, 591.25, 114, 302.2, 496.4, 597, 596, 616.7, 834.3, 980.3, 1064.6, 251.9, 253.75, 284.8, 318.3, 526.5, 627.5, 768, 770.3, 229.58, 323.8, 376.3, 470.85, 611.7, 797.38, 963.6, 1047.25, 334, 404.7, 517, 459, 338, 545.5, 189, 378, 515, 593, 670, 736, 931, 1003, 1325, 1391, 1457, 1523, 1590, 1664, 1769, 124.3, 176.5, 201.5, 502.1, 602.6), Porosity = c(50.22, 44.26, 39.31, NA, 40.38, 39.65, 35.3, 40.48, 40.13, 34.8, 18.52, NA, NA, 32.1, NA, NA, 39.79, 1.62, 1.71, NA, 14.55, 36.87, 39.08, 37.67, 16.9, NA, NA, NA, 30.5, NA, 46.52, 43.18, 33.33, 31.35, NA, 26.74, 26.4, NA, 36.19, 26.88, 27.2, NA, 11.9, 7.65, 9.25, 5.74, 40.71, 27.98, 47.6, 14.03, 20.62, 30.27, 27.51, 33.83, 9.16, 32.2, 26.71, 24.99, 20.1, 47.76, 28.54, 33.54, 23.74, 29.04, 45.38, 37.09, 43.14, 30.46, NA, NA, 30.7, 22.51, NA, 42.94, NA, NA, 29.39, 24.72, 22.36, 25.39, 45.26, 36.23, 41.38, 22, 7.6, NA, 24.09, 30.53, 36.18, NA, 25.19, 37.93, 42.95, 37.84, 47.21, 41.69, 13.64, 34.81, NA, NA, 38.39, 12.31, 9.46, 12.09, 10.3, 11.02, 10.36, 9.27, 10.17, 29.38, 35.67, 42.38, 37.54, 15.44), Conductivity = c(1.28, 1.38, 1.47, 1.13, 0.98, 1.83, 2.2,
[R] combining matrices from a list into a multidimensional array
I get some results back from running an iterative analysis in the form of a list of matrices. What I would like to do with this list is combine it such that all the similar components get combined into a multidimensional array. If possible I'd like to put results[[1]]$resultmean and results[[2]]$resultmean into a 3x3x2 array, and also put results[[1]]$resultsd and results[[2]]$resultsd in a separate 3x3x2 array. I'm sure this has been asked before, can someone point me in the right direction? Thanks J results [[1]] [[1]]$resultmean [,1] [,2] [,3] [1,] 1.00 0.768552 0.5743416 [2,] 1.307785 1.00 0.7500699 [3,] 1.747145 1.340882 1.000 [[1]]$resultsd [,1] [,2] [,3] [1,] 0. 0.05495972 0.03390511 [2,] 0.09326529 0. 0.05718047 [3,] 0.10250638 0.10124427 0. [[2]] [[2]]$resultmean [,1] [,2] [,3] [1,] 1.00 0.8280938 0.6170682 [2,] 1.213807 1.000 0.7472884 [3,] 1.631536 1.3479570 1.000 [[2]]$resultsd [,1] [,2] [,3] [1,] 0. 0.05942645 0.05017175 [2,] 0.08719565 0. 0.06344005 [3,] 0.13576301 0.11621178 0. === Dr. Jim Maas University of East Anglia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] expand.grid
Hello list. I feel like an idiot. There exists a method called expand.grid which, from the documentation, appears to do just what I want, but then it doesn't, and I can't get it to behave. Given a dataframe dfr-data.frame(c1=c(a, b, NA, a, a), c2=c(d, NA, d, e, e), c3=c(g, h, i, j, k)) I would like to have a dataframe with all (unique) combinations of all the factors present. In fact, I would like a simple solution for these two cases: given the three factor columns above, I would like both all _possible_ combinations of the factor levels, and all _present_ combinations of the factor levels (e.g. if I would do this for the first 4 rows of dfr, it would contain no combinations with c3=k). It would also be nice to be able to choose whether or not NA's are included. I'm convinced that some package holds a readymade solution, and I'm trying to switch from always writing my own stuff (get the number of levels per column, then use some apply magic) to using what is there, so thanks for any hints, Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be/ http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove [[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] tips for looping over a category for beginner
Hi, If you don't find droplevels(), then you should install the latest version of R (2.12.1). It's always a good thing, even more if you're starting. Ivan Le 1/19/2011 01:27, Ben Harrison a écrit : Thanks for the reply Peter. On 18 January 2011 22:52, Peter Ehlersehl...@ucalgary.ca wrote: Since you don't provide data, let's borrow from the help(droplevels) page: I had no joy with my R install finding droplevels exactly, but found this instead: ??droplevels gdata::drop.levels Drop unused factor levels Is that the same? aq- transform(airquality, Month = factor(Month, labels = month.abb[5:9])) str(aq) #'data.frame': 153 obs. of 6 variables: | # $ Ozone : int 41 36 12 18 NA 28 23 19 | # $ Solar.R: int 190 118 149 313 NA NA 29 | # $ Wind : num 7.4 8 12.6 11.5 14.3 14. | etc # $ Temp : int 67 72 74 62 56 66 65 59 | # $ Month : Factor w/ 5 levels May,Jun | # $ Day: int 1 2 3 4 5 6 7 8 9 10 ... | Now see if the following give you some R inspiration: plot(Ozone ~ Temp, data = aq) This highlights one of the very confusing aspects of R language for me; is plot(x, y) the same as plot (y ~ x)? Seems to be, but maybe I'm missing some nuance. plot(Ozone ~ Temp, data = aq, subset = {Month == Sep}) boxplot(Ozone ~ Month, data = aq) boxplot(Ozone ~ Month, data = aq, subset = {Month != Aug}) boxplot(Ozone ~ Month, data = aq, subset = {!(Month %in% c(Jul, Aug))}) boxplot(Ozone ~ Month, data = droplevels(subset(aq, subset = {Month != Aug}))) boxplot(Ozone ~ Month, data = droplevels(subset(aq, !(Month %in% c(Jul, Aug) Thanks for these examples, they mostly make sense! BTW, attach() is not usually a good idea; have a look at ?with. Great, I thought I had that trick nailed. Obviously there needs to be an R equivalent of l2tabu. Cheers, Ben. [[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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dataframe: string operations on columns
Well, my solution with the loop might be slower (even though I don't see any difference with my system, at least with up to 100 lines and 3 strings to separate), but it works whatever the number of strings. But I should have renamed the columns outside of the loop: names(df)[2:3] - paste(a, 1:2, sep=) ##or a more general solution for the indexes Ivan Le 1/19/2011 01:42, Niels Richard Hansen a écrit : On 2011-01-18 08:14, Ivan Calandra wrote: Hi, I guess it's not the nicest way to do it, but it should work for you: #create some sample data df- data.frame(a=c(A B, C D, A C, A D, B D), stringsAsFactors=FALSE) #split the column by space df_split- strsplit(df$a, split= ) #place the first element into column a1 and the second into a2 for (i in 1:length(df_split[[1]])){ df[i+1]- unlist(lapply(df_split, FUN=function(x) x[i])) names(df)[i+1]- paste(a,i,sep=) } I hope people will give you more compact solutions. HTH, Ivan You can replace the loop with df - transform(df, a1 = sapply(df_split, [[, 1), a2 = sapply(df_split, [[, 2)) df - cbind(df, do.call(rbind, df_split) seems to do the same (up to column names) but faster. However, all the solutions rely on there being exactly two strings when you split. The different solutions behave differently if this assumption is violated and none of them really checks this. You can, for instance, check this with all(sapply(df_split, length) == 2) Best, Niels R. Hansen Peter Ehlers Le 1/18/2011 16:30, boris pezzatti a écrit : Dear all, how can I perform a string operation like strsplit(x, ) on a column of a dataframe, and put the first or the second item of the split into a new dataframe column? (so that on each row it is consistent) Thanks Boris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] question about result of loglinear analysis
Hi: Well, you fit a saturated model. How many degrees of freedom do you have left for error? The fact that the standard errors are so huge relative to the estimates is a clue. Taking a look at your data, it's pretty clear that nation 3 is an outstanding outlier on its own. It is clearly - nay, blatantly - different from the other nations in the sample. Look at boxplot(fre ~ nation, data = data_Analysis) boxplot(sqrt(fre) ~ nation, data = data_Analysis) the latter to deal with the huge outlier near 1200 in the original data. Even on the square root scale, nation 3 sticks out like a sore thumb. 43/77 of your responses have zero frequency, so you should probably be looking into zero-inflated Poisson models and some of its relatives. Here is one citation to get you started: http://www.jstatsoft.org/v27/i08/paper Package VGAM also has functionality to fit these types of models. Using package sos, I typed # Install package sos first if you don't have it: library(sos) findFn('zero Poisson') which found 255 matches; you should find several packages that pertain to zero-inflated/zero-altered Poisson models. In the absence of the scientific background behind the data, the dominance of nation 3 may well mask more subtle effects among the other nations, so you might want to consider analyses with and without nation 3. HTH, Dennis On Tue, Jan 18, 2011 at 5:45 PM, Lao Meng laomen...@gmail.com wrote: Hi all: Here's a question about result of loglinear analysis. There're 2 factors:area and nation.The raw data is in the attachment. I fit the saturated model of loglinear with the command: glm_sat-glm(fre~area*nation, family=poisson, data=data_Analysis) After that,I extract the coefficients: result_sat-summary(glm_sat) result_coe-result_sat$coefficients I find that all the coeffients are 1 or very near to 1. How does this happen?Why all the coeffients are 1 or very near to 1? Thanks! My best __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tips for looping over a category for beginner
On 2011-01-18 16:27, Ben Harrison wrote: [...snip...] plot(Ozone ~ Temp, data = aq) This highlights one of the very confusing aspects of R language for me; is plot(x, y) the same as plot (y ~ x)? Seems to be, but maybe I'm missing some nuance. plot has many methods; see with methods(plot). If you go to the help page for plot you'll be pointed to plot.default and plot.formula (under 'See Also'). Have a look at those to see what the difference is. The formula method is useful in that it permits you to set the 'data' argument (which obviates the need for 'attach'ing. [...snip...] BTW, attach() is not usually a good idea; have a look at ?with. Great, I thought I had that trick nailed. Obviously there needs to be an R equivalent of l2tabu. I wouldn't call it a sin, but I find alternatives like with() and 'data=' much more convenient. Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cannot allocate vector of size ... in RHLE5 PAE kernel
Thank you very much Hugo for your answer. Yesterday I was out of my office and I couldn't test the advise you gave me. Today I'll do it. I have never used C, so I have to ask. For creating an executable file with your code, I copied and pasted the text into a text file, and then tried from the command line: $ gcc memorytest.c -o memorytes.out and I got the following warning: memorytest.c: In function ‘main’: memorytest.c:5: warning: return type of ‘main’ is not ‘int’ Is this important ? After your answer, I will execute this program just before the line that rises the error message, and I'll let you know today. Thank you very much Hugo, Cheers, -- === Linux user #454569 -- Ubuntu user #17469 === 2011/1/18 Hugo Mildenberger hugo.mildenber...@web.de: Hello Mauricio, Today I lost several messages from r-help and also forgot to include you in the reply-to address list previously. I'm curious what the test program I already proposed in my answer to r-help reveals. I modified it a bit to force the operating system to actually provide the memory. On an old 32 bit notebook with 512 MB of physical RAM having X running in parallel, this test program takes about a minute or so, but eventually succeeds. --- snip --- #include stdlib.h #include stdio.h #include string.h void main() { const size_t size = 10LU; fprintf(stderr,Trying to allocate %lu bytes ... ,(unsigned long)size); fflush(stderr); void *p = malloc(size); if ( p ) { fprintf(stderr,success. Now trying to commit memory ... ); fflush(stderr); memset(p,0,size); fprintf(stderr,succeeded.\n); }else { fprintf(stderr,allocation of %lu bytes failed:%m\n,(unsigned long) size); } } --- snip --- put this into a file named, say, tmalloc.c and compile it using gcc tmalloc.c -o tmalloc Best regards Hugo Mildenberger __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] count of factors
Hello everyone, I have a data set like this: head( fish_transect) ID_TRANSECT ID_PROJECT DE_ZONE DE_LOCALITY DE_SECTOR MES 1 42 MB TarragonaCreixell Control I 9 2 42 MB TarragonaCreixell Control I 9 3 42 MB TarragonaCreixell Control I 9 4 42 MB TarragonaCreixell Control I 9 5 42 MB TarragonaCreixell Control I 9 6 42 MB TarragonaCreixell Control I 9 ID_SPECIES WEIGHT SIZE NFAMILIA 1 Spondyliosoma cantharus15.64 10 1Sparidae 2 Symphodus melanocercus 11.21 10 1 Labridae 3 Diplodus vulgaris 30.20 10 2 Sparidae 4 Diplodus vulgaris 52.24 12 2 Sparidae 5 Diplodus sargus221.4114 5Sparidae 6 Diplodus annularis 3.47 6 1Sparidae The table function of the column FAMILIA gives: Apogonidae Atherinidae Blennidae BlenniidaeBothidae 216 1 406 2 11 Carangidae Centracanthidae Congridae Gadidae Gobidae 25 4 21 2 214 HaemulidaeLabridae MugilidaeMullidae Muraenidae 256381 10 965 45 Myliobatidae Sciaenidae ScombridaeScorpaenidae Serranidae 2 159 1 512 2127 SparidaeSphyraenidaeSynodontidaeTorpedinidae Trachinidae 6196 5 1 1 1 Tripterygidae 135 I want to add a new column familia2 where those families with low number of individuals are listed as other, that is, for these families Atherinidae BlenniidaeBothidae Carangidae Centracanthidae 1 2 11 25 4 Congridae Gadidae Haemulidae Mugilidae Muraenidae 21 2 25 10 45 Myliobatidae ScombridaeSphyraenidaeSynodontidae Torpedinidae 2 1 5 1 1 Trachinidae 1 I want them in column familia2 to be named others I've been trying to do a loop telling R to write others when the sum of FAMILIA was less than 50, but it didn't work because FAMILIA is a factor, and there isn't a count function (or I didn't find it). I also tried other options like the match function, level function, etc. I know I can do it manually typing by myself the names of the 16 families but I want to learn a way to do where I don't need to type the names. Thanks in advance! Lucia -- View this message in context: http://r.789695.n4.nabble.com/count-of-factors-tp3224791p3224791.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] ANNOUNCEMENT: Chapman Hall/CRC: The R Series
We are pleased to announce the launch of a new series of books on R. Chapman Hall/CRC: The R Series Aims and Scope This book series reflects the recent rapid growth in the development and application of R, the programming language and software environment for statistical computing and graphics. R is now widely used in academic research, education, and industry. It is constantly growing, with new versions of the core software released regularly and more than 2,600 packages available. It is difficult for the documentation to keep pace with the expansion of the software, and this vital book series provides a forum for the publication of books covering many aspects of the development and application of R. The scope of the series is wide, covering three main threads: • Applications of R to specific disciplines such as biology, epidemiology, genetics, engineering, finance, and the social sciences. • Using R for the study of topics of statistical methodology, such as linear and mixed modeling, time series, Bayesian methods, and missing data. • The development of R, including programming, building packages, and graphics. The books will appeal to programmers and developers of R software, as well as applied statisticians and data analysts in many fields. The books will feature detailed worked examples and R code fully integrated into the text, ensuring their usefulness to researchers, practitioners and students. Series Editors John M. Chambers (Department of Statistics, Stanford University, USA; j...@stat.stanford.edu) Torsten Hothorn (Institut für Statistik, Ludwig-Maximilians-Universität, München, Germany; torsten.hoth...@stat.uni-muenchen.de) Duncan Temple Lang (Department of Statistics, University of California, Davis, USA; dun...@wald.ucdavis.edu) Hadley Wickham (Department of Statistics, Rice University, Houston, Texas, USA; had...@rice.edu) Call for Proposals We are interested in books covering all aspects of the development and application of R software. If you have an idea for a book, please contact one of the series editors above or one of the Chapman Hall/CRC statistics acquisitions editors below. Please provide brief details of topic, audience, aims and scope, and include an outline if possible. We look forward to hearing from you. Best regards, Rob Calver (rob.cal...@informa.com) David Grubbs (david.gru...@taylorandfrancis.com) John Kimmel (john.kim...@taylorandfrancis.com) The information contained in this email message may be confidential. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. Although this message and any attachments are believed to be free of viruses, no responsibility is accepted by Informa for any loss or damage arising in any way from receipt or use thereof. Messages to and from the company are monitored for operational reasons and in accordance with lawful business practices. If you have received this message in error, please notify us by return and delete the message and any attachments. Further enquiries/returns can be sent to postmas...@informa.com Taylor Francis Group is a trading name of Informa UK Limited, registered in England under no. 1072954 The information contained in this email message may be confidential. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. Although this message and any attachments are believed to be free of viruses, no responsibility is accepted by Informa for any loss or damage arising in any way from receipt or use thereof. Messages to and from the company are monitored for operational reasons and in accordance with lawful business practices. If you have received this message in error, please notify us by return and delete the message and any attachments. Further enquiries/returns can be sent to postmas...@informa.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] useR! 2011: abstract submission registration open
We are happy to inform you that abstract submission and registration for useR! 2011 is now available online, see http://www.R-project.org/useR-2011 This meeting of the R user community will take place at the University of Warwick, Coventry, UK, August 16-18, 2011. The conference schedule comprises invited lectures and user-contributed sessions. In addition half-day tutorials presented by R experts will run on August 15, 2011, prior to the conference. We invite you to submit abstracts for oral or poster presentations on innovative and exciting applications of R. The call for papers along with the link for abstract submission is available at http://www.R-project.org/useR-2011/#Call In addition to the regular contributed talks, all participants are invited to present a Lightning Talk, for which no abstract is required. These talks provide a 5-minute platform to speak on any R-related topic and should particularly appeal to R newbies. Participants wishing to give such a talk must provide an informative title on their registration form. We hope to see you in Coventry! The organizing committee: John Aston, Julia Brettschneider, David Firth, Ashley Ford, Ioannis Kosmidis, Tom Nichols, Elke Thönnes and Heather Turner ___ r-annou...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] grid.table with head of two rows
Here is a more clear example: # Create the ftable object oftable-ftable(Titanic, row.vars = 4,col.vars=c(2,3)) require(gridExtra) #Draw the grid, but the rows and heads are missing grid.draw(tableGrob(oftable, show.csep=TRUE, show.rsep=TRUE, show.box=TRUE, separator=grey, name=table2headrows)) # I only can add 1 head and row labels grid.gedit(table2headrows, cols=attributes(oftable)$col.vars$Sex, rows=attributes(oftable)$row.vars$Survived, gpar.corefill = gpar(fill=white, col=NA), grep=TRUE, global=TRUE) -- View this message in context: http://r.789695.n4.nabble.com/grid-table-with-head-of-two-rows-tp3219992p3224772.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] Problem in using bdh function for Govt tickers
Hi, all I wanted to fetch data from Bloomberg for govt bonds, and analyse it further. I am having trouble in getting data as when I use field=PX_LAST, it is giving the prices but when I use field=CPN, or ISSUE_DT, it is not giving the results and just bouncing back NA for that. This is the piece of code: library(rJava) Warning message: package 'rJava' was built under R version 2.12.1 library(RBloomberg) k-as.POSIXct(2010-12-29) field-c(PX_LAST) ticker-c(912828JV Govt,912828JY Govt) conn - blpConnect() R version 2.12.0 (2010-10-15) rJava Version 0.8-8 RBloomberg Version 0.4-146 Java environment initialized successfully. Looking for most recent blpapi3.jar file... Adding C:\blp\API\APIv3\JavaAPI\v3.3.3.3\lib\blpapi3.jar to Java classpath Bloomberg API Version 3.3.3.3 data-bdh(conn,ticker,field,k,k) data ticker date PX_LAST 1 912828JV Govt 2010-12-29 100. 2 912828JY Govt 2010-12-29 100.0625 field-c(PX_LAST,CPN) data-bdh(conn,ticker,field,k,k) data ticker date PX_LAST CPN 1 912828JV Govt 2010-12-29 100. NA 2 912828JY Govt 2010-12-29 100.0625 NA I am a new R user, I have looked over for a similar problem but dint find any. Any suggestions?? [[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] Odp: count of factors
Hi r-help-boun...@r-project.org napsal dne 19.01.2011 09:51:43: Hello everyone, I have a data set like this: head( fish_transect) ID_TRANSECT ID_PROJECT DE_ZONE DE_LOCALITY DE_SECTOR MES 1 42 MB TarragonaCreixell Control I 9 2 42 MB TarragonaCreixell Control I 9 3 42 MB TarragonaCreixell Control I 9 4 42 MB TarragonaCreixell Control I 9 5 42 MB TarragonaCreixell Control I 9 6 42 MB TarragonaCreixell Control I 9 ID_SPECIES WEIGHT SIZE NFAMILIA 1 Spondyliosoma cantharus15.64 10 1Sparidae 2 Symphodus melanocercus 11.21 10 1 Labridae 3 Diplodus vulgaris 30.20 10 2 Sparidae 4 Diplodus vulgaris 52.24 12 2 Sparidae 5 Diplodus sargus221.4114 5Sparidae 6 Diplodus annularis 3.47 6 1Sparidae The table function of the column FAMILIA gives: snip I want to add a new column familia2 where those families with low number of individuals are listed as other, that is, for these families Atherinidae BlenniidaeBothidae Carangidae Centracanthidae 1 2 11 25 4 Congridae Gadidae Haemulidae Mugilidae Muraenidae 21 2 25 10 45 Myliobatidae ScombridaeSphyraenidaeSynodontidae Torpedinidae 2 1 5 1 1 Trachinidae 1 Use levels make new column fish_transect$familia2 - fish_transect$familia change levels levels(fish_transect$familia2)[which(table(fish_transect$familia2)46)]-other You can use any threshold number. Regards Petr BTW you need to have familia as factor not as character variable. I want them in column familia2 to be named others I've been trying to do a loop telling R to write others when the sum of FAMILIA was less than 50, but it didn't work because FAMILIA is a factor, and there isn't a count function (or I didn't find it). I also tried other options like the match function, level function, etc. I know I can do it manually typing by myself the names of the 16 families but I want to learn a way to do where I don't need to type the names. Thanks in advance! Lucia -- View this message in context: http://r.789695.n4.nabble.com/count-of-factors- tp3224791p3224791.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] combining matrices from a list into a multidimensional array
Hi: Try this: lapply(results, function(x) array(unname(unlist(x)), c(3, 3, 2))) HTH, Dennis On Wed, Jan 19, 2011 at 12:31 AM, Maas James Dr (MED) j.m...@uea.ac.ukwrote: I get some results back from running an iterative analysis in the form of a list of matrices. What I would like to do with this list is combine it such that all the similar components get combined into a multidimensional array. If possible I'd like to put results[[1]]$resultmean and results[[2]]$resultmean into a 3x3x2 array, and also put results[[1]]$resultsd and results[[2]]$resultsd in a separate 3x3x2 array. I'm sure this has been asked before, can someone point me in the right direction? Thanks J results [[1]] [[1]]$resultmean [,1] [,2] [,3] [1,] 1.00 0.768552 0.5743416 [2,] 1.307785 1.00 0.7500699 [3,] 1.747145 1.340882 1.000 [[1]]$resultsd [,1] [,2] [,3] [1,] 0. 0.05495972 0.03390511 [2,] 0.09326529 0. 0.05718047 [3,] 0.10250638 0.10124427 0. [[2]] [[2]]$resultmean [,1] [,2] [,3] [1,] 1.00 0.8280938 0.6170682 [2,] 1.213807 1.000 0.7472884 [3,] 1.631536 1.3479570 1.000 [[2]]$resultsd [,1] [,2] [,3] [1,] 0. 0.05942645 0.05017175 [2,] 0.08719565 0. 0.06344005 [3,] 0.13576301 0.11621178 0. === Dr. Jim Maas University of East Anglia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Barplot and line x-axis positions
On 01/19/2011 04:04 AM, Andy Aldersley wrote: Hello all, Hoping that there is a fairly simple solution to my query... I'm trying to overlay a line plot of some data onto a barplot of different data. The y-axes are different for each set of data but the x-axes are the same (1:12, corresponding with 12 months of observations). The problem I'm having is that the centre of the bars and the points on line don't match up, which is making the whole thing look untidy. I'm wondering if there is a way for me to specify the positions of the centre of each bar on the graph. The code I have is as follows: xvals- barplot(wetMeans[,i], yaxt='n', axisnames=F, xlab='', ylab='', main=names[i], border=F, cex.main=0.7)par(new=T)plot(burnMeans[,i], yaxt='n', xlab='', ylab='', type='b', cex=1, pch=16, lty=44, col='black', lwd=1.5) As you can see I have suppressed the y-axis so this isn't a problem.I have also tried using the barp function in the plotrix package. This solved the problem of centring the bars on the graph, but when I overlay the line it seems to use different tick points on the x-axis. Again, I'm not sure why this is but if there is a quick fix that would be much appreciated. library(plotrix)xvals- barp(wetMeans[,i], xlab='', ylab='', main=names[i], col='grey')par(new=T)plot(burnMeans[,i], yaxt='n', xlab='', ylab='', type='b', cex=1, pch=16, lty=44, col='black', lwd=1.5) I get the same result even if I suppress the x-axis in the plot command. Hi Andy, You seem to be heading in the right direction. barplot returns the centers of the bars, and if you use the lines function to draw your lines with these as the x values, you should get the lines in the correct place. barp centers the bars on integer values by default, and returns both the x and y values in a list. Again, using lines should do what you want. If you are trying to use plot to get the lines, beware, you may not get the same plot extents unless you specify xlim= for both. If this doesn't help, try sending some real or fake data and a sample plot. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] expand.grid
G'day Nick, On Wed, 19 Jan 2011 09:43:56 +0100 Nick Sabbe nick.sa...@ugent.be wrote: Given a dataframe dfr-data.frame(c1=c(a, b, NA, a, a), c2=c(d, NA, d, e, e), c3=c(g, h, i, j, k)) I would like to have a dataframe with all (unique) combinations of all the factors present. Easy: R expand.grid(lapply(dfr, levels)) c1 c2 c3 1 a d g 2 b d g 3 a e g 4 b e g 5 a d h 6 b d h 7 a e h 8 b e h 9 a d i 10 b d i 11 a e i 12 b e i 13 a d j 14 b d j 15 a e j 16 b e j 17 a d k 18 b d k 19 a e k 20 b e k In fact, I would like a simple solution for these two cases: given the three factor columns above, I would like both all _possible_ combinations of the factor levels, and all _present_ combinations of the factor levels (e.g. if I would do this for the first 4 rows of dfr, it would contain no combinations with c3=k). R dfrpart - lapply(dfr[1:4,], factor) R expand.grid(lapply(dfrpart, levels)) c1 c2 c3 1 a d g 2 b d g 3 a e g 4 b e g 5 a d h 6 b d h 7 a e h 8 b e h 9 a d i 10 b d i 11 a e i 12 b e i 13 a d j 14 b d j 15 a e j 16 b e j It would also be nice to be able to choose whether or not NA's are included. R expand.grid(lapply(dfrpart, function(x) c(levels(x), + if(any(is.na(x))) NA else NULL))) c1 c2 c3 1 ad g 2 bd g 3 NAd g 4 ae g 5 be g 6 NAe g 7 a NA g 8 b NA g 9 NA NA g 10ad h 11bd h HTH. Cheers, Berwin == Full address Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Maths and Stats (M019)+61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009e-mail: ber...@maths.uwa.edu.au Australiahttp://www.maths.uwa.edu.au/~berwin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] expand.grid
slaps self in forehead/ I appear to have misinterpreted the help: considering that it explicitly makes note of factors, I wrongly assumed that it would use the levels of a factor automatically. My bad. For completeness' sake, my final solution: getLevels-function(vec, includeNA=FALSE, onlyOccurring=FALSE) { if(onlyOccurring) { rv-levels(factor(vec)) } else { rv-levels(vec) } #cat(levels so far: , rv, \n) if(includeNA any(is.na(vec))) { rv-c(rv,NA) } #cat(levels with na: , rv, \n) return(rv) } expand.combs-function(dfr, includeNA=FALSE, onlyOccurring=FALSE) { expand.grid(lapply(dfr, getLevels, includeNA, onlyOccurring)) } Thx. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: Berwin A Turlach [mailto:ber...@maths.uwa.edu.au] Sent: woensdag 19 januari 2011 11:04 To: Nick Sabbe Cc: r-help@r-project.org Subject: Re: [R] expand.grid G'day Nick, On Wed, 19 Jan 2011 09:43:56 +0100 Nick Sabbe nick.sa...@ugent.be wrote: Given a dataframe dfr-data.frame(c1=c(a, b, NA, a, a), c2=c(d, NA, d, e, e), c3=c(g, h, i, j, k)) I would like to have a dataframe with all (unique) combinations of all the factors present. Easy: R expand.grid(lapply(dfr, levels)) c1 c2 c3 1 a d g 2 b d g 3 a e g 4 b e g 5 a d h 6 b d h 7 a e h 8 b e h 9 a d i 10 b d i 11 a e i 12 b e i 13 a d j 14 b d j 15 a e j 16 b e j 17 a d k 18 b d k 19 a e k 20 b e k In fact, I would like a simple solution for these two cases: given the three factor columns above, I would like both all _possible_ combinations of the factor levels, and all _present_ combinations of the factor levels (e.g. if I would do this for the first 4 rows of dfr, it would contain no combinations with c3=k). R dfrpart - lapply(dfr[1:4,], factor) R expand.grid(lapply(dfrpart, levels)) c1 c2 c3 1 a d g 2 b d g 3 a e g 4 b e g 5 a d h 6 b d h 7 a e h 8 b e h 9 a d i 10 b d i 11 a e i 12 b e i 13 a d j 14 b d j 15 a e j 16 b e j It would also be nice to be able to choose whether or not NA's are included. R expand.grid(lapply(dfrpart, function(x) c(levels(x), + if(any(is.na(x))) NA else NULL))) c1 c2 c3 1 ad g 2 bd g 3 NAd g 4 ae g 5 be g 6 NAe g 7 a NA g 8 b NA g 9 NA NA g 10ad h 11bd h HTH. Cheers, Berwin == Full address Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Maths and Stats (M019)+61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009e-mail: ber...@maths.uwa.edu.au Australiahttp://www.maths.uwa.edu.au/~berwin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] table on factors with non-ASCII characters *extremely* slow on Windows
Running ‘table’ on a factor with levels containing non-ASCII characters seems to result in *extremely* bad performance on Windows. Here’s a simple example with benchmark results (I’ve reduced the number of replications to make the function finish within reasonable time): library(rbenchmark) x.num=sample(1:2, 10^5, replace=TRUE) x.fac.ascii=factor(x.num, levels=1:2, labels=c(A,B)) x.fac.nascii=factor(x.num, levels=1:2, labels=c(Æ,Ø)) benchmark( table(x.num), table(x.fac.ascii), table(x.fac.nascii), table(unclass(x.fac.nascii)), replications=20 ) test replications elapsed relative user.self sys.self user.child sys.child 4 table(unclass(x.fac.nascii)) 201.53 4.636364 1.51 0.01 NANA 2 table(x.fac.ascii) 200.33 1.00 0.33 0.00 NANA 3 table(x.fac.nascii) 20 146.67 444.454545 38.52 81.74 NANA 1 table(x.num) 201.55 4.696970 1.53 0.01 NANA sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Norwegian-Nynorsk_Norway.1252 LC_CTYPE=Norwegian-Nynorsk_Norway.1252 LC_MONETARY=Norwegian-Nynorsk_Norway.1252 [4] LC_NUMERIC=C LC_TIME=Norwegian-Nynorsk_Norway.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] rbenchmark_0.3 Running the same test (but 100 replications) on a Linux system with R.12.1 Patched results in no difference between the performance on ASCII factors and non-ASCII factors: test replications elapsed relative user.self sys.self user.child sys.child 4 table(unclass(x.fac.nascii)) 100 4.607 3.096102 4.455 0.092 0 0 2 table(x.fac.ascii) 100 1.488 1.00 1.459 0.028 0 0 3 table(x.fac.nascii) 100 1.616 1.086022 1.560 0.051 0 0 1 table(x.num) 100 4.504 3.026882 4.403 0.079 0 0 sessionInfo() R version 2.12.1 Patched (2011-01-18 r54033) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=nn_NO.UTF-8 LC_NUMERIC=C LC_TIME=nn_NO.UTF-8 [4] LC_COLLATE=nn_NO.UTF-8 LC_MONETARY=C LC_MESSAGES=nn_NO.UTF-8 [7] LC_PAPER=nn_NO.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=nn_NO.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rbenchmark_0.3 Can anyone else reproduce this? I see no theoretical reason why the level names of the factor should matter, as the factors are internally stored as numeric values (cf. the results of ‘table(unclass(x.fac.nascii))’), and the level names are only needed when displaying the results. BTW, ‘tabulate’ on x.fac.nascii is extremely fast, on both Windows and Linux. I guess at least for simple cases one could use something like res=tabulate(x.fac.nascii, nbins=nlevels(x.fac.nascii)) names(res)=levels(x.fac.nascii) though I’m not entirely sure the internal structure of factors is guaranteed to be so that this will always work. Any comments or suggestions? -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2, geom_hline and facet_grid
Having upgraded to R version 2.12.1 I still have the same problem: The combination of facet_grid and geom_hline produce (for me) 4 panels of which two are empty of any data or lines (labelled 1 and 2). Removing either the facet_grid or the geom_hline gives me the result I would then expect. I have tried forcing the rhythm to be a factor Anyone have any ideas? Sandy Dennis Murphy wrote: Hi: The attached plot comes from the following code: g - ggplot(data =f, aes(x = (variable_time + fixed_time)/2, y variable_time - fixed_time)) g + geom_point() + geom_hline(yintercept =) + facet_grid(ecd_rhythm ~ .) Is this what you were expecting? sessionInfo() R version 2.12.1 Patched (2010-12-18 r53869) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=glish_United States.1252 [2] LC_CTYPE=glish_United States.1252 [3] LC_MONETARY=glish_United States.1252 [4] LC_NUMERIC=nbsp; [5] LC_TIME=glish_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets grid [8] methods base other attached packages: [1] data.table_1.5.1 doBy_4.2.2 R2HTML_2.2 contrast_0.13 [5] Design_2.3-0 Hmisc_3.8-3 survival_2.36-2 sos_1.3-0 [9] brew_1.0-4 lattice_0.19-17 ggplot2_0.8.9proto_0.3-8 [13] reshape_0.8.3plyr_1.4 loaded via a namespace (and not attached): [1] cluster_1.13.2 digest_0.4.2 Matrix_0.999375-46 reshape2_1.1 [5] stringr_0.4tools_2.12.1 HTH, Dennis On Tue, Jan 18, 2011 at 1:46 AM, Small Sandy (NHS Greater Glasgow Clyde) sandy.sm...@nhs.net ailto:sandy.sm...@nhs.net%22 wrote: Hi I have a long data set on which I want to do Bland-Altman style plots for each rhythm type Using ggplot2, when I use geom_hline with facet_grid I get an extra set of empty panels. I can't get it to do it with the Diamonds data supplied with the package so here is a (much abbreviated) example: lvexs cvd_basestudy ecd_rhythm fixed_time variable_time 1 CBP05J02 AF30.9000 29.4225 2 CBP05J02 AF33.1700 32.0350 3 CBP05J02 AF32.5700 30.2775 4 CBP05J02 AF32.0550 33.7275 5 CBP05J02 SINUS30.9175 28.3475 6 CBP05J02 SINUS30.5725 29.7450 7 CBP05J02 SINUS33. 31.1550 9 CBP05J02 SINUS31.8350 30.7000 10 CBP05J02 SINUS34.0450 33.4800 11 CBP05J02 SINUS31.3975 29.8150 qplot((variable_time + fixed_time)/2, variable_time - fixed_time, data=exs) + facet_grid(ecd_rhythm ~ .) + geom_hline(yintercept=0) If I take out the geom_hline I get the plots I would expect. It doesn't seem to make any difference if I get the mean and difference separately. Can anyone explain this and tell me how to avoid it (and why does it work with the Diamonds data set? Any help much appreciated - thanks. Sandy Sandy Small Clinical Physicist NHS Forth Valley and NHS Greater Glasgow and Clyde This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] predict.lme() gives missings for new subjects
Hi, why does predict.lme() give missings in the predict.Subject column for Subjects which are not in the original training set? library(nlme) example(predict.lme) ## c.f. Subject==F30 has missing values. How can I predict/impute values for such new Subjects based on the fitted model? Thanks in advance, Will __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] printing big real values
Hello, I have a file with very big values. I want to display the real values with classic ways (without exposant) summary(a[,1]); Min. 1st Qu.Median Mean 3rd Qu. Max. 1.198e+09 1.199e+09 1.200e+09 1.200e+09 1.201e+09 1.202e+09 Can you help please? Regards Adel -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[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] printing big real values
Try this: options(scipen = 20) summary(a[,1]) On Wed, Jan 19, 2011 at 9:36 AM, Adel ESSAFI adeless...@gmail.com wrote: Hello, I have a file with very big values. I want to display the real values with classic ways (without exposant) summary(a[,1]); Min. 1st Qu.Median Mean 3rd Qu. Max. 1.198e+09 1.199e+09 1.200e+09 1.200e+09 1.201e+09 1.202e+09 Can you help please? Regards Adel -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Analyzing texts with tm
Hey everybody! I have to use R's tm package to do some text analysis, first thing would be to create a term frequency matrix. Digging in tm's source code it seems like it uses some logic like this to create term frequencies: data(crude) (txt - Content(crude[[1]])) (tokTxt - unlist(strsplit(gsub([^[:alnum:]]+, , txt), , fixed = TRUE))) table(factor(tokTxt, levels = c('two'))) table(factor(tokTxt, levels = c('two days'))) Like this code example demostrates the tokenization of the input text makes it impossible to use a group of words separated by whitespace as input words. So my question is: How would you create such a term frequency matrix in R? Here's some Ruby code I once wrote to show what I want: txt = some text containing two days\n freq = ['two', 'two days'].inject({}) { |h,w| h[w] = txt.scan(Regexp.compile( #{w} )).length; h } (Reads as: Given txt: Generate an associative array mapping words to the word's frequency in txt. To count occurences do not split the text at whitespace but instead use a regular expression to search for the word/group of words surrounded by whitespace in txt.) Thanks in advance for any input! -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cannot allocate vector of size ... in RHLE5 PAE kernel
I got the following warning: memorytest.c: In function ‘main’: memorytest.c:5: warning: return type of ‘main’ is not ‘int’ Is this important ? Hello Mauricio, No, your gcc version is unduly puristic here. The traditional return type of the main function in C should be int, and if that is given, main has to return an integer number explicitly. By convention, a main function returning 0 indicates success, and anything other is considered as an error or warning condition. Specifying void main() normally implies returning zero. But if you are still worried simply change void main into int main() and add the statement return 0; just before the last curly bracket (without quotation marks, of course): int main() { [...] return 0; } Best Hugo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: count of factors
Thanks a lot Petr!! It worked! -- View this message in context: http://r.789695.n4.nabble.com/count-of-factors-tp3224791p3224924.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] det(X,log=TRUE)
Hello R-help, I recently spent a lot of time debugging a program, and the problem turned out to be my own misuse of the det() function. A simple recreation of the problem would be X - diag (c(2,2,2)) det (X,log=TRUE) ## returns 8 as opposed to log 8 I had simply assumed that (along with many other basic R functions, such as dnorm etc) det can take an argument of log=TRUE and give you the log of the answer. At the very least, if it didn't do this, then I would get an unused argument error. The argument log=TRUE wasn't used (because now I have looked at the code for det, I see it supplies its own argument to determinant()) so is it not possible to return this error? I guess it is something to do with the way ... behaves. Alternatively, is there a way for me to set up R so that it will tell me if arguments to functions with ... aren't really being used? Many Thanks James Lawrence. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cannot allocate vector of size ... in RHLE5 PAE kernel
Dear Hugo, I tried your memory test program (without further modifications) just after the gc() command: print(gc()) print(gcinfo(TRUE)) system(/mypath/memorytest.out) and the result that I got was: Number of simulations read from ' Particles.txt ' : 9000 --- used (Mb) gc trigger (Mb) max used (Mb) Ncells 480114 12.91816453 48.6 5543382 148.1 Vcells 5256970 40.2 119171871 909.3 322607910 2461.4 [1] TRUE Trying to allocate 10 bytes ... success. Now trying to commit memory ... succeeded. Garbage collection 2667 = 2286+194+187 (level 2) ... 12.9 Mbytes of cons cells used (26%) 278.4 Mbytes of vectors used (29%) Error: cannot allocate vector of size 476.2 Mb What do you understand of this result ? Thanks in advance, Mauricio -- === Linux user #454569 -- Ubuntu user #17469 === 2011/1/19 Hugo Mildenberger hugo.mildenber...@web.de: I got the following warning: memorytest.c: In function ‘main’: memorytest.c:5: warning: return type of ‘main’ is not ‘int’ Is this important ? Hello Mauricio, No, your gcc version is unduly puristic here. The traditional return type of the main function in C should be int, and if that is given, main has to return an integer number explicitly. By convention, a main function returning 0 indicates success, and anything other is considered as an error or warning condition. Specifying void main() normally implies returning zero. But if you are still worried simply change void main into int main() and add the statement return 0; just before the last curly bracket (without quotation marks, of course): int main() { [...] return 0; } Best Hugo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] LDA variables dropping similar within group
Dear R-users: I am R-usser begginer and at the same time a beginner running discriminant analysis; I wanted to perform a DA using just the 80ß% of the original data but I have some problems with simmilarity in variables, Here my Skript set.seed(123) data80 - data[sample(472, 378), ] data80 #Remove all missing values listwise data80.withoutna-na.omit(data80) #Group variable data_grouping80-data80.withoutna[,2] data_grouping80 #dim(data80) #Possible independent variables variables80-data80.withoutna[,4:447] variables80 #Data set for discriminant analysis ldadataset80-cbind(data_grouping80,variables80) ldadataset80 #Discriminant analysis as SPSS does it (excluded variables by SPSS, denoted by -) library(MASS) model_lda80-lda(data_grouping80 ~. ,data=ldadataset80, prior=c(255/471,100/471,76/471,40/471)) model_lda80-lda(data_grouping80 ~. -CHLOSTA-DIGGRAN-DRYFILMA-EQUSYLV-EUPALPI-GERPHAE-GERROBE-HYPORAD-JUNCOMNA-JUNEFFU-JUNFILI-JUNJAQU-JUNTRIF-KNAARVE-KNAMAXI-KOBMYOS-KOEHIRS-KOEPYRA-LASHALL-LASKRAP-LATLAEV-LATPRAT-LEOHISP-LEUALPI-LEUVULG- LILMART-LINCART-LISOVAT-LOIPROC-LOLPERE-LOTCORSL-LUZCAMP-LUZLUTE-LUZLUZO-LUZPILO-LUZSPIC-LUZSYLV-LYCALPI-MAIBIFO-MELPRAT-MELSYLV-MENAQUA-MINGERA-MOECILI-MOLCAER-MUTADON-MYOALPE-MYOARVE-MYODECU-MYOSCOR- NARSTRI-NIGRHEL-ONOMONT-OREDIST-OXYCAMP-PARLILI-PARPALU-PEDELON-PEDFOLI-PEDROSC-PEDTUBE-PEDVERT-PELAPHT-PERBIST-PERVIVI-PEUOSTR-PHLCOMM-PHLPRAT-PHLRHAE-PHYBETO-PHYHEMI-PHYORBI-PHYOVAT-PICABIE-PIMMAJO- PIMSAXI-PINCEMB-PINMUG-PINVULG-PLAALPI-PLAATRA-PLABIFOL-PLALANC-PLAMEDI-PLESCHR-POAALPI-POAAMAR-POAANN-POAPRAT-POASUPI-POATRIV-POAVARI-POLALPE-POLAMAR-POLCOMO-POLJUNI-POLVULG-POTANSE-POTAURE-POTCRAN-POTEREC- POTGRAND-PRIAURI-PRIELAT-PRIFARI-PRIMINI-PRIVERI-PRUGRAN-PRUVULG-PSEALBI-PULALPAL-PULALPAP-PULANGU-PULVERN-PYRCHLO-PYRMEDI-RANACON-RANACRI-RANBULB-RANMONT-RANNEMO-RHIALEC-RHIGLAC-RHIMINO-RHOFERR-RHYSQUA- RHYTRIQ-ROSPEND-RUMACELL-RUMACET-RUMALPE-RUMALPI-RUMOBTU-RUMSCUT-SAGINASP-SALAURI-SALHERB-SALRETI-SALRETU-SALVPRA-SANMINO-SANOFFI-SCACANE-SCACOLU-SCALUCI-SCOAUTU-SCOHELV-SCOHUMI-SCOMONT-SELSELA-SEMARAC- SEMMONT-SEMWULF-SENABRO-SENDORO-SENINCA--SESALBI-SIBPROCU-SILACAU-SILDIOI-SILLATI-SILNUTA-SILVULG-SOLALPI-SOLMINI-SOLPUSI-SOLVIRG-SORAUCU-STEGRAM-STEMEDI-TARALPI-TAROFFI-THAAQUI-THEALPI-THYPRAE-THEPYR- THYPULE-THYSERP-TOFCALY-TRAGLOB-TRAPRAT-TRIALPE-TRIALPI-TRIBADI-TRICESP-TRIFLAV-TRIMEDI-TRIMONT-TRIPRAT-TRIREPE-TROEURO-URTDIOI-VACGAUL-VACMYRT-VACVITI-VALMONT-VALOFFI-VERALBU-VERALPI-VERBELL-VERCHAM- VERFRUT-VEROFFI-VERSERP-VICCRAC-VIOBIFL-VIOCANI-VIOHIRT-VIOTHOM-VIOTRIC-WILSTIP ,data=ldadataset80) ##New variables# (variables 82 103 128 146 181 appear to be constant within groups) #I got as an answer that some variables are constant within groups, so I delete them fro the data as follows set.seed(123) data80 - data[sample(472, 378), ] data80 newdata80 - data80[c(-82,-103,-128,-146,-181)] newdata80 #Then I computed the whole analisis again, but then i got the same answer at the end, just in this case the variables are different.. #Remove all missing values listwise newdata80.withoutna-na.omit(newdata80) newdata80.withoutna #Group variable ndata_grouping80-newdata80.withoutna[,2] ndata_grouping80 dim(newdata80) #Possible independent variables nvariables80-newdata80.withoutna[,4:442] nvariables80 ldadatasetn80-cbind(ndata_grouping80,nvariables80) ldadatasetn80 library(MASS) model_ldan80-lda(ndata_grouping80 ~. -CHLOSTA-DIGGRAN-DRYFILMA-EQUSYLV-EUPALPI-GERPHAE-GERROBE-HYPORAD-JUNCOMNA-JUNEFFU-JUNFILI-JUNJAQU-JUNTRIF-KNAARVE-KNAMAXI-KOBMYOS-KOEHIRS-KOEPYRA-LASHALL-LASKRAP-LATLAEV-LATPRAT-LEOHISP-LEUALPI-LEUVULG- LILMART-LINCART-LISOVAT-LOIPROC-LOL...,data=ldadatasetn80) Were an I falling? I can´t understand this seceond answer wit new similar variables when I alreday drop the ´variables that initially were similar within groups ones said .. Thank you very much in advance Kind regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Accessing MySQL Database in R
Folks, 1. can you pelase cite the messages you are repsonding to? 2. Can you please include the original poster of the question who is not necessarily subscribed to the list? Thanks, Uwe Ligges On 18.01.2011 09:52, Joel wrote: You could try useing '127.0.0.1' instead of 'localhost' and see if that works. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] question about result of loglinear analysis
Date: Wed, 19 Jan 2011 01:20:06 -0800 From: djmu...@gmail.com To: laomen...@gmail.com CC: r-help@r-project.org Subject: Re: [R] question about result of loglinear analysis Hi: Well, you fit a saturated model. How many degrees of freedom do you have left for error? The fact that the standard errors are so huge relative to the estimates is a clue. Taking a look at your data, it's pretty clear that nation 3 is an outstanding outlier on its own. It is clearly - nay, blatantly - different from the other nations in the sample. Look at boxplot(fre ~ nation, data = data_Analysis) boxplot(sqrt(fre) ~ nation, data = data_Analysis) I'm scrolling back though my cygwin windoh, last night I used this, ( read data into x not data_Analysis) x-read.table(area_nation.txt,header=TRUE) str(x) 'data.frame': 77 obs. of 3 variables: $ area : int 1 1 1 1 1 1 1 1 1 1 ... $ nation: int 1 2 3 4 5 6 7 8 9 10 ... $ fre : int 0 0 85 2 0 0 0 0 1 0 ... library(scatterplot3d) library(rgl) scatterplot3d(x$area,x$nation,x$fre,type=h) scatterplot3d(x$area,x$nation,log(x$fre+1),type=h) there is always a discussion here on looking at pictures and post hoc analysis or what is legitimate to do with outliers that may be confusing to some readers but you always need to keep in mind your overall objectives here. It often helps to forget for a minute that you are doing something intellectual or pompous and just stare at the pictures ( or someone else quoted a statistician talking about getting rat dropping under your finger nails presumably meaning getting more familiar with details of your data aqusition system LOL). the latter to deal with the huge outlier near 1200 in the original data. Even on the square root scale, nation 3 sticks out like a sore thumb. 43/77 of your responses have zero frequency, so you should probably be looking into zero-inflated Poisson models and some of its relatives. Here is one citation to get you started: http://www.jstatsoft.org/v27/i08/paper Package VGAM also has functionality to fit these types of models. Using package sos, I typed # Install package sos first if you don't have it: library(sos) findFn('zero Poisson') which found 255 matches; you should find several packages that pertain to zero-inflated/zero-altered Poisson models. In the absence of the scientific background behind the data, the dominance of nation 3 may well mask more subtle effects among the other nations, so you might want to consider analyses with and without nation 3. HTH, Dennis On Tue, Jan 18, 2011 at 5:45 PM, Lao Meng wrote: Hi all: Here's a question about result of loglinear analysis. There're 2 factors:area and nation.The raw data is in the attachment. I fit the saturated model of loglinear with the command: glm_sat-glm(fre~area*nation, family=poisson, data=data_Analysis) After that,I extract the coefficients: result_sat-summary(glm_sat) result_coe-result_sat$coefficients I find that all the coeffients are 1 or very near to 1. How does this happen?Why all the coeffients are 1 or very near to 1? Thanks! My best __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Data Extraction/threshold/
X959X967X968 X9591 -0.04 0.45 X967-0.04 1 -0.09 X9680.45-0.09 1 X968_2 0.76-0.16 0.82 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Nnet Questions
Hi, I am new to nueral networks and R. i want run the NN using nnet. Following are my Questions. 1 To run regression using nnet, why should i specify linout=T always?. if not it is not prediciting properly 2In the help, i have read that linout, entropy, softmax and censored are mutually exclusive. Still i am able to specify all at a time. When should i use? 3 any example for contrasts parameter 4 -- View this message in context: http://r.789695.n4.nabble.com/Nnet-Questions-tp3225406p3225406.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] Nnet Questions
Hi, I am using nnet function to run regression and classification algorihtms. following are my questions 1. test-nnet(Strength~.,cement,skip=T,size=0,linout=T), why linout=T always for Regression algorithm 2. In the help, linout, entropy, softmax and censored are mutually exclusive. but i can use all at a time. can anybody helps me use of each parameter by example 3. how contrasts is used and please provide an examle -- View this message in context: http://r.789695.n4.nabble.com/Nnet-Questions-tp3225409p3225409.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] cannot allocate vector of size ... in RHLE5 PAE kernel
Dear Mauricio, what I do not understand at all is the message: Error: cannot allocate vector of size 476.2 Mb Have you tried to allocate a big matrix in between, whith the R - statement not being shown in the output? Probably not. If not, your local R version is buggy for sure. The test shows that the OS imposes no artificial constraint on memory consumption, at least not up to ~ 1GB. But because you said that you're running a 32 - bit version of R (in a virtual machine?), the question is now wether gcc also compiles the test program as a 32 - bit program. I'm unsure because a 64 - bit system can be configured to compile and run programs using either environment. Regrettably I previously did not include a test for that. --- snip --- #include stdio.h int main() { printf(The size of a pointer is %lu bytes\n, (unsigned long)sizeof(void *)); return 0; } --- snip --- If the program says The size of a pointer is 4 bytes then you're running the test program in a 32 bit environment. Then the allocation problem could possibly be solved by recompiling/updating your R version. The system is called Redhat Enterprise Linux after all, so calling in Redhat support at that point and ask them to do something for their money should be an option. Best Hugo On Wednesday 19 January 2011 12:54:38 Mauricio Zambrano wrote: Dear Hugo, I tried your memory test program (without further modifications) just after the gc() command: print(gc()) print(gcinfo(TRUE)) system(/mypath/memorytest.out) and the result that I got was: Number of simulations read from ' Particles.txt ' : 9000 --- used (Mb) gc trigger (Mb) max used (Mb) Ncells 480114 12.91816453 48.6 5543382 148.1 Vcells 5256970 40.2 119171871 909.3 322607910 2461.4 [1] TRUE Trying to allocate 10 bytes ... success. Now trying to commit memory ... succeeded. Garbage collection 2667 = 2286+194+187 (level 2) ... 12.9 Mbytes of cons cells used (26%) 278.4 Mbytes of vectors used (29%) Error: cannot allocate vector of size 476.2 Mb What do you understand of this result ? Thanks in advance, Mauricio I got the following warning: memorytest.c: In function ‘main’: memorytest.c:5: warning: return type of ‘main’ is not ‘int’ Is this important ? Hello Mauricio, No, your gcc version is unduly puristic here. The traditional return type of the main function in C should be int, and if that is given, main has to return an integer number explicitly. By convention, a main function returning 0 indicates success, and anything other is considered as an error or warning condition. Specifying void main() normally implies returning zero. But if you are still worried simply change void main into int main() and add the statement return 0; just before the last curly bracket (without quotation marks, of course): int main() { [...] return 0; } Best Hugo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cannot allocate vector of size ... in RHLE5 PAE kernel
Thanks again Hugo, 2011/1/19 Hugo Mildenberger hugo.mildenber...@web.de: Dear Mauricio, what I do not understand at all is the message: Error: cannot allocate vector of size 476.2 Mb Have you tried to allocate a big matrix in between, whith the R - statement not being shown in the output? If I understood correctly your question, in between the lines I showed you before: print(gc()) print(gcinfo(TRUE)) system(/dataMZB/2011/memorytest.out) I didn't try to allocate a matrix, and the R output was a message printed just before those three lines. Probably not. If not, your local R version is buggy for sure. The test shows that the OS imposes no artificial constraint on memory consumption, at least not up to ~ 1GB. But because you said that you're running a 32 - bit version of R (in a virtual machine?), I'm running a 32 bits OS in a 64 bits hardware, by using a kernel with PAE extension, in order to see the 12 Gb of ram that I have: $ uname -a Linux mymachine 2.6.18-238.el5PAE #1 SMP Sun Dec 19 14:42:44 EST 2010 i686 i686 i386 GNU/Linux the question is now wether gcc also compiles the test program as a 32 - bit program. I'm unsure because a 64 - bit system can be configured to compile and run programs using either environment. Regrettably I previously did not include a test for that. --- snip --- #include stdio.h int main() { printf(The size of a pointer is %lu bytes\n, (unsigned long)sizeof(void *)); return 0; } --- snip --- The output of that program was: The size of a pointer is 4 bytes so, I confirmed that I'm running a 32 bits OS. If the program says The size of a pointer is 4 bytes then you're running the test program in a 32 bit environment. Then the allocation problem could possibly be solved by recompiling/updating your R version. I think is the right way of solving this. At the other hand, yesterday a friend suggested me to install R in a live CD with a 64 GNU/Linux OS, to run my script and see if I get the same error. I'll also try this. The system is called Redhat Enterprise Linux after all, so calling in Redhat support at that point and ask them to do something for their money should be an option. What is sadly funny, is the fact that when I asked the IT guys of my work if it is possible to ask support for software compilation/installation in RHLE, they told me that is NOT possible, because the money they are paying in licences is for network maintenanceand other corporative stuff. So far, RHLE only have brought problems to me (this is one of many), problems that I never had while using Ubuntu, but unfortunately at work RHEL was the only possible choice. I'll let you know if I'm able to overcome this issue. Thanks a lot for your help, Cheers, Mauricio -- === Linux user #454569 -- Ubuntu user #17469 === Best Hugo On Wednesday 19 January 2011 12:54:38 Mauricio Zambrano wrote: Dear Hugo, I tried your memory test program (without further modifications) just after the gc() command: print(gc()) print(gcinfo(TRUE)) system(/mypath/memorytest.out) and the result that I got was: Number of simulations read from ' Particles.txt ' : 9000 --- used (Mb) gc trigger (Mb) max used (Mb) Ncells 480114 12.9 1816453 48.6 5543382 148.1 Vcells 5256970 40.2 119171871 909.3 322607910 2461.4 [1] TRUE Trying to allocate 10 bytes ... success. Now trying to commit memory ... succeeded. Garbage collection 2667 = 2286+194+187 (level 2) ... 12.9 Mbytes of cons cells used (26%) 278.4 Mbytes of vectors used (29%) Error: cannot allocate vector of size 476.2 Mb What do you understand of this result ? Thanks in advance, Mauricio I got the following warning: memorytest.c: In function ‘main’: memorytest.c:5: warning: return type of ‘main’ is not ‘int’ Is this important ? Hello Mauricio, No, your gcc version is unduly puristic here. The traditional return type of the main function in C should be int, and if that is given, main has to return an integer number explicitly. By convention, a main function returning 0 indicates success, and anything other is considered as an error or warning condition. Specifying void main() normally implies returning zero. But if you are still worried simply change void main into int main() and add the statement return 0; just before the last curly bracket (without quotation marks, of course): int main() { [...] return 0; } Best Hugo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 find more about Covariance (in R)
Hello everyone, I am trying to understand how covariance work. So I created a vector called sr-c(2,5,7,5,2) so according to wikipedia Cov(X,X)=E[XX]-E[x]*E[x] which in R is mean(sr*sr)-mean(sr)*mean(sr) [1] 3.76 but also cov(sr,sr) [1] 4.7 why is this difference between these two approaches? Where I am wrong? I would like to thank you in advance for your help Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Error Moran's test : reconsider test arguments
Dear R-users, I was wondering if someone could give me some advices on the following problem. I tried to apply moranâs test to a small dataset and couldnât succeed, here is the error message:  mor - moran.test(x, res2)  Avis dans moran.test(x, res2) :  Out-of-range p-value: reconsider test arguments  mor   Moran's I test under randomization data: x weights: res2  Moran I statistic standard deviate = NaN, p-value = NA alternative hypothesis: greater sample estimates: Moran I statistic      Expectation         Variance      -0.0417      -0.0417       0.   It seems that I have a problem computing the standard deviation, variance and/or p-value. As a brief overview of what are x and res2: I have a square sample plot on the field divided into 5 lines / 5 columns and one value per âsub-plotâ, so a dataframe of 25 values (25 cells and 1 value per cellâ¦). The parameter x is a numeric vector containing those 25 values: str(x) num [1:25] 22920 19546 16170 21387 9499 ... To obtain my spatial weight matrix, I used 2 columns (X Y) representing the coordinates of the center of each sub-plot (20x20m, so 10:10, 10:30, 10:50, etc.), transformed it into a neighborhood matrix of class ânbâ with dnearneigh() function, then into a object of class âlistwâ with nb2listw() function (with style=âBâ).  I end up with âres2â : res2 Characteristics of weights list object: Neighbour list object: Number of regions: 25 Number of nonzero links: 600 Percentage nonzero weights: 96 Average number of links: 24  Weights style: B Weights constants summary:   n nn S0  S1   S2 B 25 625 600 1200 57600  Ok so it seems quiet straightforward to me and I cannot figure out from where my problem is coming !!! any idea ? with regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to find more about Covariance (in R)
Hi Alex, cov() uses the formula for a sample covariance. The denominator is N - 1 instead of N. However, the formula you used from Wikipedia is for a population covariance. To move between the two in this case: cov(sr, sr) * (4/5) # should equal E[XX] - E[x] * E[x] Cheers, Josh On Wed, Jan 19, 2011 at 6:29 AM, Alaios ala...@yahoo.com wrote: Hello everyone, I am trying to understand how covariance work. So I created a vector called sr-c(2,5,7,5,2) so according to wikipedia Cov(X,X)=E[XX]-E[x]*E[x] which in R is mean(sr*sr)-mean(sr)*mean(sr) [1] 3.76 but also cov(sr,sr) [1] 4.7 why is this difference between these two approaches? Where I am wrong? I would like to thank you in advance for your help Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 University of California, Los Angeles http://www.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] How to find more about Covariance (in R)
Dear Josh, I would like to thank you for your reply. I think that it is clear that I miss a lot of theory. I have tried in google to read and study more about covariance but I have this feeling that the term 'covariance' is used for many different things in different topics. You mentioned for example population and sample (covariance) which are two words-terms that I can not distinguish between them. Even though this is R list could you please provide me some differences to study more about covariance before trying to implement things in R. (Even in R are some things that do not understand i.e pearson, kendal and spearman method) I would like to thank you in advance for your patience. Best Regards Alex --- On Wed, 1/19/11, Joshua Wiley jwiley.ps...@gmail.com wrote: From: Joshua Wiley jwiley.ps...@gmail.com Subject: Re: [R] How to find more about Covariance (in R) To: Alaios ala...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Wednesday, January 19, 2011, 2:36 PM Hi Alex, cov() uses the formula for a sample covariance. The denominator is N - 1 instead of N. However, the formula you used from Wikipedia is for a population covariance. To move between the two in this case: cov(sr, sr) * (4/5) # should equal E[XX] - E[x] * E[x] Cheers, Josh On Wed, Jan 19, 2011 at 6:29 AM, Alaios ala...@yahoo.com wrote: Hello everyone, I am trying to understand how covariance work. So I created a vector called sr-c(2,5,7,5,2) so according to wikipedia Cov(X,X)=E[XX]-E[x]*E[x] which in R is mean(sr*sr)-mean(sr)*mean(sr) [1] 3.76 but also cov(sr,sr) [1] 4.7 why is this difference between these two approaches? Where I am wrong? I would like to thank you in advance for your help Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 University of California, Los Angeles http://www.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] R scheduling request
You could include a call to the source function that will read and run an R script (I have not tried this, but don't see any reason that it would not work). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Alessandro Oggioni [mailto:a.oggi...@ise.cnr.it] Sent: Tuesday, January 18, 2011 6:33 AM To: Greg Snow Cc: r-help Subject: Re: [R] R scheduling request Many thanks Greg! I try to use tcltk2 and tclTaskSchedule function but in argument expr is possible to insert a R script? Have you an example? Alessandro Il 17 gennaio 2011 22.02.51 UTC+1, Greg Snow greg.s...@imail.org ha scritto: You could write a batch file and then have your OS schedule to run R on the batch file whenever you want (see Rscript for one approach of running the batch). Inside of R you can use Sys.sleep to wait a certain amount of time before running the next command. If you load the tcltk2 package then you can use the tclTaskSchedule function. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Alessandro Oggioni Sent: Saturday, January 15, 2011 6:19 AM To: r-help Subject: [R] R scheduling request Dear all, I have used R.rps to produce a Google API chart (googleVis) with a data request in another server. But i don't understand how is possible to scheduling a request data to the server and after produce a update of the charts. Thanks in advance. Alessandro Oggioni __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2, geom_hline and facet_grid
Hi Sandy, It's difficult to know what's going wrong without a small reproducible example (https://github.com/hadley/devtools/wiki/Reproducibility) - could you please provide one? You might also have better luck with an email directly to the ggplot2 mailing list. Hadley On Wed, Jan 19, 2011 at 2:57 AM, Sandy Small sandy.sm...@nhs.net wrote: Having upgraded to R version 2.12.1 I still have the same problem: The combination of facet_grid and geom_hline produce (for me) 4 panels of which two are empty of any data or lines (labelled 1 and 2). Removing either the facet_grid or the geom_hline gives me the result I would then expect. I have tried forcing the rhythm to be a factor Anyone have any ideas? Sandy Dennis Murphy wrote: Hi: The attached plot comes from the following code: g - ggplot(data =f, aes(x = (variable_time + fixed_time)/2, y variable_time - fixed_time)) g + geom_point() + geom_hline(yintercept =) + facet_grid(ecd_rhythm ~ .) Is this what you were expecting? sessionInfo() R version 2.12.1 Patched (2010-12-18 r53869) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=glish_United States.1252 [2] LC_CTYPE=glish_United States.1252 [3] LC_MONETARY=glish_United States.1252 [4] LC_NUMERIC=nbsp; [5] LC_TIME=glish_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets grid [8] methods base other attached packages: [1] data.table_1.5.1 doBy_4.2.2 R2HTML_2.2 contrast_0.13 [5] Design_2.3-0 Hmisc_3.8-3 survival_2.36-2 sos_1.3-0 [9] brew_1.0-4 lattice_0.19-17 ggplot2_0.8.9 proto_0.3-8 [13] reshape_0.8.3 plyr_1.4 loaded via a namespace (and not attached): [1] cluster_1.13.2 digest_0.4.2 Matrix_0.999375-46 reshape2_1.1 [5] stringr_0.4 tools_2.12.1 HTH, Dennis On Tue, Jan 18, 2011 at 1:46 AM, Small Sandy (NHS Greater Glasgow Clyde) sandy.sm...@nhs.net ailto:sandy.sm...@nhs.net%22 wrote: Hi I have a long data set on which I want to do Bland-Altman style plots for each rhythm type Using ggplot2, when I use geom_hline with facet_grid I get an extra set of empty panels. I can't get it to do it with the Diamonds data supplied with the package so here is a (much abbreviated) example: lvexs cvd_basestudy ecd_rhythm fixed_time variable_time 1 CBP05J02 AF 30.9000 29.4225 2 CBP05J02 AF 33.1700 32.0350 3 CBP05J02 AF 32.5700 30.2775 4 CBP05J02 AF 32.0550 33.7275 5 CBP05J02 SINUS 30.9175 28.3475 6 CBP05J02 SINUS 30.5725 29.7450 7 CBP05J02 SINUS 33. 31.1550 9 CBP05J02 SINUS 31.8350 30.7000 10 CBP05J02 SINUS 34.0450 33.4800 11 CBP05J02 SINUS 31.3975 29.8150 qplot((variable_time + fixed_time)/2, variable_time - fixed_time, data=exs) + facet_grid(ecd_rhythm ~ .) + geom_hline(yintercept=0) If I take out the geom_hline I get the plots I would expect. It doesn't seem to make any difference if I get the mean and difference separately. Can anyone explain this and tell me how to avoid it (and why does it work with the Diamonds data set? Any help much appreciated - thanks. Sandy Sandy Small Clinical Physicist NHS Forth Valley and NHS Greater Glasgow and Clyde This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem in using bdh function for Govt tickers
That's a Bloomberg issue, not RBloomberg: use bdp() (point) instead of bdh() (history) or bds() (set) bdp(conn,ticker,c(PX_LAST,CPN)) PX_LAST CPN 912828JV Govt NA 0.875 912828JY Govt 100.0234 0.875 HTH, David L. Reiner XR Trading LLC -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of nikhil Sent: Wednesday, January 19, 2011 3:11 AM To: r-help@r-project.org Subject: [R] Problem in using bdh function for Govt tickers Hi, all I wanted to fetch data from Bloomberg for govt bonds, and analyse it further. I am having trouble in getting data as when I use field=PX_LAST, it is giving the prices but when I use field=CPN, or ISSUE_DT, it is not giving the results and just bouncing back NA for that. This is the piece of code: library(rJava) Warning message: package 'rJava' was built under R version 2.12.1 library(RBloomberg) k-as.POSIXct(2010-12-29) field-c(PX_LAST) ticker-c(912828JV Govt,912828JY Govt) conn - blpConnect() R version 2.12.0 (2010-10-15) rJava Version 0.8-8 RBloomberg Version 0.4-146 Java environment initialized successfully. Looking for most recent blpapi3.jar file... Adding C:\blp\API\APIv3\JavaAPI\v3.3.3.3\lib\blpapi3.jar to Java classpath Bloomberg API Version 3.3.3.3 data-bdh(conn,ticker,field,k,k) data ticker date PX_LAST 1 912828JV Govt 2010-12-29 100. 2 912828JY Govt 2010-12-29 100.0625 field-c(PX_LAST,CPN) data-bdh(conn,ticker,field,k,k) data ticker date PX_LAST CPN 1 912828JV Govt 2010-12-29 100. NA 2 912828JY Govt 2010-12-29 100.0625 NA I am a new R user, I have looked over for a similar problem but dint find any. Any suggestions?? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, XR Content) are confidential and proprietary to XR Trading, LLC (XR) and/or its affiliates, and are protected by intellectual property laws. Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates. THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to find more about Covariance (in R)
Hi, On Wed, Jan 19, 2011 at 9:59 AM, Alaios ala...@yahoo.com wrote: Dear Josh, I would like to thank you for your reply. I think that it is clear that I miss a lot of theory. I have tried in google to read and study more about covariance but I have this feeling that the term 'covariance' is used for many different things in different topics. You mentioned for example population and sample (covariance) which are two words-terms that I can not distinguish between them. Even though this is R list could you please provide me some differences to study more about covariance before trying to implement things in R. Free online intro to statistics class: http://webcast.berkeley.edu/course_details_new.php?seriesid=2009-D-87303 Or, if you prefer iTunes: http://itunes.apple.com/us/itunes-u/statistics-2-001-fall-2009/id354822870 (Even in R are some things that do not understand i.e pearson, kendal and spearman method) It's not R that you're not understanding ... if you want to use R for statistics, you need to first learn a bit about statistics. You won't suddenly be able to do statistics just by learning how to use R. Sorry, there's no shortcut on this one. Good luck, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 old packages to work on R 2.12.1
I just installed R 2.12.1, and when I went to run a few old programs with it, nothing worked. I got a ton of error messages saying such and such package was built before R 2.10.0 and needed to be reinstalled. These were not just warning messages, but error messages that prevent the programs from running when they were running just fine with R 2.10.1 For some of those packages, such as deSolve, I can't find any recent versions to download to correct the problem. So my first question is, is there a way around this error that doesn't require actually installing recent versions of all those old packages? I suppose I could just use R 2.10.1, but suppose at some point I want to use both an old package and a new package that was built under R 2.12.1 in the same program? That has happened by the way. I wanted to use deSolve and yags. Since I don't have an old version of yags, I had to install the current version on CRAN, and it won't work under 2.10.1. My second question is, if not, should the R developers reconsider their strategic decision to invalidate packages just because they were built under early versions of R? I would be willing to bet that for many users, the improvements from R 2.10.1 to R 2.12.1 are minor compared with the hassle caused by the fact that their old programs will no longer work. This especially complicates application development, where the R programmer is not the end user. What developer is going to use R for his applications if he can't even be sure they will work under future versions? Joe Boyer Principal Statistician GSK Department of Statistical Sciences 8-275-3661 external: 610-787-3661 [[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 get old packages to work on R 2.12.1
On Jan 19, 2011, at 9:49 AM, Joseph Boyer wrote: I just installed R 2.12.1, and when I went to run a few old programs with it, nothing worked. I got a ton of error messages saying such and such package was built before R 2.10.0 and needed to be reinstalled. These were not just warning messages, but error messages that prevent the programs from running when they were running just fine with R 2.10.1 For some of those packages, such as deSolve, I can't find any recent versions to download to correct the problem. So my first question is, is there a way around this error that doesn't require actually installing recent versions of all those old packages? I suppose I could just use R 2.10.1, but suppose at some point I want to use both an old package and a new package that was built under R 2.12.1 in the same program? That has happened by the way. I wanted to use deSolve and yags. Since I don't have an old version of yags, I had to install the current version on CRAN, and it won't work under 2.10.1. My second question is, if not, should the R developers reconsider their strategic decision to invalidate packages just because they were built under early versions of R? I would be willing to bet that for many users, the improvements from R 2.10.1 to R 2.12.1 are minor compared with the hassle caused by the fact that their old programs will no longer work. This especially complicates application development, where the R programmer is not the end user. What developer is going to use R for his applications if he can't even be sure they will work under future versions? The burden of determining when and how you update R and any contributed packages is on you, not the R Core developers. R's SDLC is well known and is also documented in: http://www.r-project.org/doc/R-FDA.pdf Specifically as it pertains to contributed packages, the total burden is on the package authors/maintainers to keep their packages up to date with R as new versions are released. If a new version of R breaks an old package as a result of core functionality changes, then the contributed package authors and maintainers have been remiss in not keeping up to date with R's development process, since such changes are announced well in advance and beta releases of R are made available for testing prior to release. There is no absolute guarantee that a contributed package will work for all future versions of R. A package maintainer may elect to stop maintaining the package at any time, by choice or otherwise. We are all volunteers and mortal... Frankly, that is no different than if you were using a commercial package with third party contributed functionality. You don't indicate what OS you are running on, but according to CRAN, deSolve is available in both source and binary package form: http://cran.us.r-project.org/web/packages/deSolve/index.html for current versions of R. With respect to yags, AFAICS, it is not on CRAN, but on R-Forge: https://r-forge.r-project.org/R/?group_id=329 which means that you may need to contact the package maintainer regarding whether or not his package is being actively maintained and available for your unstated OS and perhaps why it is not on CRAN, which would improve availability. The tests on R-Forge would seem to suggest that it is working with 2.12.1. The general solution may be as simple as running update.packages(...) depending upon your OS. If on Windows, see: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f That being said, in general, it is best to cleanly install both a new version of R and the associated contributed packages that you require. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CCF and missing values.
Hi, I have missing values in my time series. na.action = na.pass works for acf and pacf. Why do I get the following error for the ccf? ts(matrix(c(dev$u[1:10],dev$q[1:10]),ncol=2),start=1,freq=1) Time Series: Start = 1 End = 10 Frequency = 1 Series 1 Series 2 1 68.0 138.4615 2 70.0 355.5556 3 68.76000 304.3200 4 68.0 231.4286 5 69.74194 357.4963 6 NA NA 7 67.45455 174.8697 8 66.0 144. 9 73.5 287.6471 10 70.0 172.6027 ccf(x = ts.data[,1], y = ts.data[,2], na.action = na.pass, ylab = CCF) Error in na.fail.default(as.ts(x)) : missing values in object Thank you Paul [[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] Barplot and line x-axis positions
You can use the updateusr function in the TeachingDemos package to get them to match. Sent from my iPod On Jan 18, 2011, at 10:05 AM, Andy Aldersley ajalders...@hotmail.co.uk wrote: Hello all, Hoping that there is a fairly simple solution to my query... I'm trying to overlay a line plot of some data onto a barplot of different data. The y-axes are different for each set of data but the x-axes are the same (1:12, corresponding with 12 months of observations). The problem I'm having is that the centre of the bars and the points on line don't match up, which is making the whole thing look untidy. I'm wondering if there is a way for me to specify the positions of the centre of each bar on the graph. The code I have is as follows: xvals - barplot(wetMeans[,i], yaxt='n', axisnames=F, xlab='', ylab='', main=names[i], border=F, cex.main=0.7)par(new=T)plot(burnMeans[,i], yaxt='n', xlab='', ylab='', type='b', cex=1, pch=16, lty=44, col='black', lwd=1.5) As you can see I have suppressed the y-axis so this isn't a problem.I have also tried using the barp function in the plotrix package. This solved the problem of centring the bars on the graph, but when I overlay the line it seems to use different tick points on the x-axis. Again, I'm not sure why this is but if there is a quick fix that would be much appreciated. library(plotrix)xvals - barp(wetMeans[,i], xlab='', ylab='', main=names[i], col='grey')par(new=T)plot(burnMeans[,i], yaxt='n', xlab='', ylab='', type='b', cex=1, pch=16, lty=44, col='black', lwd=1.5) I get the same result even if I suppress the x-axis in the plot command. Many thanks in advance, Andy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get old packages to work on R 2.12.1
Dear Joe, On Wed, Jan 19, 2011 at 7:49 AM, Joseph Boyer joseph.g.bo...@gsk.com wrote: I just installed R 2.12.1, and when I went to run a few old programs with it, nothing worked. I got a ton of error messages saying such and such package was built before R 2.10.0 and needed to be reinstalled. These were not just warning messages, but error messages that prevent the programs from running when they were running just fine with R 2.10.1 For some of those packages, such as deSolve, I can't find any recent versions to download to correct the problem. So my first question is, is there a way around this error that doesn't require actually installing recent versions of all those old packages? I suppose I could just use R 2.10.1, but suppose at some point I want to use both an old package and a new package that was built under R 2.12.1 in the same program? That has happened by the way. I wanted to use deSolve and yags. Since I don't have an old version of yags, I had to install the current version on CRAN, and it won't work under 2.10.1. This is not an option for your current problem, but if backwards compatibility is important, keep backups. I borrowed this idea from Debian which has stable and unstable versions. The stable ones are frozen---no more updates are done (not 100% true, but that is the gist). R is very well behaved about having multiple installs, so I typically install new versions in a new directory and then install all my packages again (I keep an R script for this). Once I am satisfied that everything I want to do works in the latest and greatest version of R + updated packages, I can delete the old versions, otherwise, I just keep both. Storage is available cheaply ( .05 USD per gigabyte), so unless you're installing all of CRAN, it should not cost much to keep duplicates. My second question is, if not, should the R developers reconsider their strategic decision to invalidate packages just because they were built under early versions of R? I do not believe that packages are invalidated because of their version. There are instances where old code no longer works, and some newer packages may also require more modern versions of packages because either the package maintainers know the older package versions do not work as they want, or they are unsure and unwilling to deal with the hassle. In any case, everything I have seen suggests that the R core team is very aware of compatibility issues and does as much as possible to keep R core stable and compatible. There have been quite a few discussions on the R-devel list about new features etc. that invariably include a discussion of what the ramifications of change would be and whether or not it is justified. I would be willing to bet that for many users, the improvements from R 2.10.1 to R 2.12.1 are minor compared with the hassle caused by the fact that their old programs will no longer work. This especially complicates application development, where the R programmer is not the end user. What developer is going to use R for his applications if he can't even be sure they will work under future versions? I think many would, do, and will. Improvement and progress necessitate change (I suspect most developers are thrilled not to be stuck using paper tape in batch mode [and my sincerest condolences to those who still fondly remember and lament the loss]). The R core team is very good about giving advance warning and providing R-devel before it is officially released which allows software developers to start working with the new code and updating their programs if necessary before the latest version of R is rolled out to general users. I know it is frustrating and a hassle when something that used to work stops (I currently work with Windows 7 x64, Windows XP x32, and Debian unstable---trying to keep all three up-to-date and working similarly keeps me on my toes and if half the things I've muttered under my breath about computers at 2am actually came to pass.), but also consider that the R core team already freely volunteer their time and (vast) skill to provide us this wonderful software. I do not think it is too much to ask that software developers and users be willing to put in some of their own time to update when there are changes and improvements to R that are, ultimately, benefiting us anyways. If it is truly too much bother and hassle for minor improvements, it may be better to only upgrade R versions at major releases (1, 2, 3, etc.). My school seems to have taken this approach and still has 1.8.1, I think, loaded on their lab computers. My $.02 (or$.05) Sincerely, Josh Joe Boyer Principal Statistician GSK Department of Statistical Sciences 8-275-3661 external: 610-787-3661 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
Re: [R] How to find more about Covariance (in R)
population is all individual. sample is a part of population. If the sample size is enough large, mean(sr*sr)-mean(sr)*mean(sr) will almost equal to cov(sr, sr). On Wed, Jan 19, 2011 at 3:59 PM, Alaios ala...@yahoo.com wrote: Dear Josh, I would like to thank you for your reply. I think that it is clear that I miss a lot of theory. I have tried in google to read and study more about covariance but I have this feeling that the term 'covariance' is used for many different things in different topics. You mentioned for example population and sample (covariance) which are two words-terms that I can not distinguish between them. Even though this is R list could you please provide me some differences to study more about covariance before trying to implement things in R. (Even in R are some things that do not understand i.e pearson, kendal and spearman method) I would like to thank you in advance for your patience. Best Regards Alex --- On Wed, 1/19/11, Joshua Wiley jwiley.ps...@gmail.com wrote: From: Joshua Wiley jwiley.ps...@gmail.com Subject: Re: [R] How to find more about Covariance (in R) To: Alaios ala...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Wednesday, January 19, 2011, 2:36 PM Hi Alex, cov() uses the formula for a sample covariance. The denominator is N - 1 instead of N. However, the formula you used from Wikipedia is for a population covariance. To move between the two in this case: cov(sr, sr) * (4/5) # should equal E[XX] - E[x] * E[x] Cheers, Josh On Wed, Jan 19, 2011 at 6:29 AM, Alaios ala...@yahoo.com wrote: Hello everyone, I am trying to understand how covariance work. So I created a vector called sr-c(2,5,7,5,2) so according to wikipedia Cov(X,X)=E[XX]-E[x]*E[x] which in R is mean(sr*sr)-mean(sr)*mean(sr) [1] 3.76 but also cov(sr,sr) [1] 4.7 why is this difference between these two approaches? Where I am wrong? I would like to thank you in advance for your help Best Regards Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 University of California, Los Angeles http://www.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Quantile Regression: Extracting Residuals
Dear R users Is there a way to obtain the residuals from a model fitted by quantile regression? Thank you. Thanaset -- View this message in context: http://r.789695.n4.nabble.com/Quantile-Regression-Extracting-Residuals-tp3225423p3225423.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] A question regarding volcano plot
I forgot to mention the plot looks like this :-( http://img402.imageshack.us/i/volcanoi.jpg/ [[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] Semi-Regular Time Series with Missing Values
I don't seem to have that method: zts = as.ts.zoo(z) Error: could not find function as.ts.zoo I'm finding forum posts from people trying to use stl directly with zoo[reg] functions (despite the documentation specifying ts) but discovering that stl gives errors with NA entries. I encountered similar errors. Can anyone on this list confirm whether stl works with NA values? If so, could someone please point me to a working example? On Tue, Jan 18, 2011 at 8:06 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Tue, Jan 18, 2011 at 6:33 PM, Adam Oliner oli...@gmail.com wrote: Hi, I'm trying to make a ts object that has both NA values and a frequency other than 1 (so I can use stl). I've tried all permutations I can think of, but cannot get the desired (expected?) results. The values live in x and the corresponding semi-regular time stamps are in t: library('zoo') z = zoo(x, order.by=t, frequency=24) zzr = as.zooreg(z, start=0) zr = zooreg(x, order.by=t, start=0, frequency=24) zrz = as.zoo(zr) The objects z, zr, and zzr all have frequency 24, as desired, and plot correctly. Object zrz plots correctly but has frequency 1. Now I try to make it a ts object: zrt = ts(zzr) ... omits the missing values. zrt = ts(zzr, frequency=24) ... omits the missing values and changes the timestamps. plot(ts(zr)) ... omits the missing values. zrt = ts(zr, frequency=24) ... omits the missing values and changes the timestamps. zrt = as.ts(zr) ... inserts 23 NA values between each legitimate value. zrt = as.ts(zr, frequency=24) ... inserts 23 NA values between each legitimate value. zrzt = ts(zrz) ... omits the missing values. zrzt = ts(zrz, frequency=24) ... omits the missing values and changes the timestamps. Note that there is an as.ts.zoo method. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- - Adam J. Oliner [[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] Three-way interaction plot
Hello All, I need to create a three-way interaction plot and I was wondering if anyone could recommend a package I could use to design these plots. Thank you! PHRI DISCLAIMER This information is directed in confidence solely to the person named above and may not otherwise be distributed, copied or disclosed. Therefore, this information should be considered strictly confidential. If you have received this email in error, please notify the sender immediately via a return email for further direction. Thank you for your assistance. [[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] A question regarding volcano plot
Hello all, I was trying to make a volcano plot with some real data, using log2(ratio) vs. Z-value significance. However the scatter of the points is too less contrary to 'normal' volcano plots and I'm getting a sharp 'V' shaped plot. *Am I doing something wrong here?* The data(ratio) is available from pastebin: http://pastebin.com/m2Jss3qF data - read.table(data.txt,header=FALSE) ratio - data$V1 ratio.mean - mean(ratio) ratio.sd - sd(ratio) ratio.log - log2(ratio) z - (ratio-ratio.mean)/(ratio.sd) z.sig - 2*pnorm(-abs(z)) z.tsig - 2*pt(-abs(z),df=length(ratio)-1)#sig from t-dist par(mfrow=c(1,4)) plot(ratio.log,-log10(z.sig)) plot(ratio.log, -log10(z.tsig)) plot(ratio.log,z.sig) plot(ratio,z) [[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] Installing package in windows 7
Hi all, I was trying to install a package called ei from this http://gking.harvard.edu/eiR link . With GCC, r-base-dev and some other R package dependencies installed it works perfect in my Ubuntu Linux system. Now I am trying to install the same in Windows 7 environment. So far my setup is as follows, 1. R installed in home folder (c:\Users\username\R-2.12.1\R. It is set to run as administrator, and the R folder is writable. 2. My working directory is (c:\Users\username\Documents) 3. Rtool is installed in (c:\Rtools) Having this setup, 4. I tried to install it by the command, install.packages(ei,repos=http://r.iq.harvard.edu;) This command gives me the following error message. --- Installing package(s) into ‘C:\Users\username\Documents/R/win-library/2.12’ (as ‘lib’ is unspecified) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘ei’ is not available --- After that I have decided to have a try to install it from a local zip file, so I proceeded in the following way, 5. I have downloaded the package ei_0.938.tar.gz, untar it and make a zip file from that. I placed it into my work directory. 6. I opened the terminal (Run cmd), went to the work directory and tried to run the command R COM INSTALL ei --- It shows me the following error message, C:\Users\username\DocumentsR COM INSTALL ei 'R' is not recognized as an internal or external command, operable program or batch file. --- I am not sure what should I do now. Is there anyone to help? _ Rdgst. -- View this message in context: http://r.789695.n4.nabble.com/Installing-package-in-windows-7-tp3225439p3225439.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] Copula and Multivariate distribution
Hi all, I understand that rmvdc generates random number from mvdc object. But the mvdc object can only be used if we define the marginals! So my question is suppose we don't find any distribution which fit marginals so we use the Canonical Maximum Likelihood method (This approach uses the empirical CDF of each marginal distribution to transform the observations into pseudo observations with uniform margins) SO after finding the copula which fit the dependancy HOW i can generate random number which mimic the data? Hope my question is clear, please if someone have an idea help me! THANKS __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Quantile Regression: Extracting Residuals
Try looking here: ?rq.object ?residuals R has excellent documentation that can answer many such questions with less than a minute of reading. -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it. - Jubal Early, Firefly r-help-boun...@r-project.org wrote on 01/19/2011 11:30:49 AM: [image removed] [R] Quantile Regression: Extracting Residuals Thanaset to: r-help 01/19/2011 02:12 PM Sent by: r-help-boun...@r-project.org Dear R users Is there a way to obtain the residuals from a model fitted by quantile regression? Thank you. Thanaset -- View this message in context: http://r.789695.n4.nabble.com/ Quantile-Regression-Extracting-Residuals-tp3225423p3225423.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] Printing pretty' vectors in Sweave
Ah! I was always trying collapse with sep and other options. Not by itself. Perfect! And yes, that was my bad example. Robin Jeffries MS, DrPH Candidate Department of Biostatistics UCLA 530-624-0428 On Tue, Jan 18, 2011 at 10:27 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Hi Robin, Have you looked at the 'collapse' argument to paste? something like: myvec - paste(1:4, collapse = , ) Might do what you want. Also maybe ?bquote or the like to get rid of quotes possibly (I'm not in a position to try presently). Side note, it is really probably best not to use 'c' as a variable name since it is such a fundamental function. Cheers, Josh On Jan 18, 2011, at 21:46, Robin Jeffries rjeffr...@ucla.edu wrote: I am trying to print a nice looking vector in Sweave. c - 1:4 I want to see (1, 2, 3, 4) in TeX. . If I use paste(c, ,, sep=) I get 1, 2, 3, 4, If use cat(c, sep=,) I can't seem to assign it to an object, 1,2,3,4 myvec - cat(c, sep=,) 1,2,3,4 myvec NULL and if I bypass the object assignment and put My vector is (\Sweave{cat(c, sep=,)}). prints out My vector is (). Suggestions? Robin Jeffries MS, DrPH Candidate Department of Biostatistics UCLA 530-624-0428 [[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] VarCorr
I have a loop that I would like to use to extract the stddev for each itteration so I can average the stddev for all the runs. It would be helpful to know how to extract the stddev for each run from the VarCorr. Thanks MCruns-1000 sighatlvec-rep(NA,MCruns) sighatbvec-rep(NA,MCruns) sighatevec-rep(NA,MCruns) for(mc in 1:MCruns) { samples-(sqrt(sigbsq)*rnorm(6)) labs-(sqrt(siglsq)*rnorm(2)) errors-(sqrt(sigesq)*rnorm(24)) y-errors+samples[sampfac]+labs[labfac] lmer-lmer(y~1+(1|sampfac)+(1|labfac)) print(VC-VarCorr(lmer)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 logistic model with random effects in R
Hello everyone, I'm quite new to R and am trying to run a logistic model to look at how various measures of boldness in individual animals influences probability of capture, however I also want to include random effects and I'm not sure how to construct a model that incorporates both of these things. Data was collected from 6 different groups of 6 individuals with 10 replicates for each group. Whether an individual was caught in a trial or not was called Catchability and the outcome is binomial (caught = 1, not caught = 0). Catchability is my response variable that I want to see if I can explain by the other variables. Individual and Group would be my random effects. I have already installed lme4 but not sure how to code for the model I need, can anyone offer any help please? The column headings in my data table are as follows. [1] Trial Group Individual Mark [5] Catchability Mboldness1 Mboldness2 Nboldness1 [9] Nboldness2 Standardlength This is the string of my data: str(data) 'data.frame': 36 obs. of 10 variables: $ Trial : int 1 2 3 4 5 6 7 8 9 10 ... $ Group : int 1 1 1 1 1 1 2 2 2 2 ... $ Individual: int 1 2 3 4 5 6 7 8 9 10 ... $ Mark : Factor w/ 8 levels - O, - P,..: 8 2 4 6 3 1 6 3 1 5 ... $ Catchability : int 1 1 1 1 0 1 1 1 1 1 ... $ Mboldness1: int 7 10 0 11 15 5 15 4 15 1 ... $ Mboldness2: int 1 270 600 1 10 203 10 230 1 580 ... $ Nboldness1: int 0 0 0 0 0 0 1 0 2 0 ... $ Nboldness2: int 270 110 50 50 90 70 130 90 260 220 ... $ Standardlength: num 40.5 37.4 38.6 41.1 39.1 40.5 50.2 60.3 53.9 55 ... Many thanks in advance, Laura __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 get old packages to work on R 2.12.1
Did you do: update.packages(checkBuilt=TRUE) Rob -- From: Joshua Wiley jwiley.ps...@gmail.com Sent: Wednesday, January 19, 2011 11:43 AM To: Joseph Boyer joseph.g.bo...@gsk.com Cc: r-help@r-project.org Subject: Re: [R] how to get old packages to work on R 2.12.1 Dear Joe, On Wed, Jan 19, 2011 at 7:49 AM, Joseph Boyer joseph.g.bo...@gsk.com wrote: I just installed R 2.12.1, and when I went to run a few old programs with it, nothing worked. I got a ton of error messages saying such and such package was built before R 2.10.0 and needed to be reinstalled. These were not just warning messages, but error messages that prevent the programs from running when they were running just fine with R 2.10.1 For some of those packages, such as deSolve, I can't find any recent versions to download to correct the problem. So my first question is, is there a way around this error that doesn't require actually installing recent versions of all those old packages? I suppose I could just use R 2.10.1, but suppose at some point I want to use both an old package and a new package that was built under R 2.12.1 in the same program? That has happened by the way. I wanted to use deSolve and yags. Since I don't have an old version of yags, I had to install the current version on CRAN, and it won't work under 2.10.1. This is not an option for your current problem, but if backwards compatibility is important, keep backups. I borrowed this idea from Debian which has stable and unstable versions. The stable ones are frozen---no more updates are done (not 100% true, but that is the gist). R is very well behaved about having multiple installs, so I typically install new versions in a new directory and then install all my packages again (I keep an R script for this). Once I am satisfied that everything I want to do works in the latest and greatest version of R + updated packages, I can delete the old versions, otherwise, I just keep both. Storage is available cheaply ( .05 USD per gigabyte), so unless you're installing all of CRAN, it should not cost much to keep duplicates. My second question is, if not, should the R developers reconsider their strategic decision to invalidate packages just because they were built under early versions of R? I do not believe that packages are invalidated because of their version. There are instances where old code no longer works, and some newer packages may also require more modern versions of packages because either the package maintainers know the older package versions do not work as they want, or they are unsure and unwilling to deal with the hassle. In any case, everything I have seen suggests that the R core team is very aware of compatibility issues and does as much as possible to keep R core stable and compatible. There have been quite a few discussions on the R-devel list about new features etc. that invariably include a discussion of what the ramifications of change would be and whether or not it is justified. I would be willing to bet that for many users, the improvements from R 2.10.1 to R 2.12.1 are minor compared with the hassle caused by the fact that their old programs will no longer work. This especially complicates application development, where the R programmer is not the end user. What developer is going to use R for his applications if he can't even be sure they will work under future versions? I think many would, do, and will. Improvement and progress necessitate change (I suspect most developers are thrilled not to be stuck using paper tape in batch mode [and my sincerest condolences to those who still fondly remember and lament the loss]). The R core team is very good about giving advance warning and providing R-devel before it is officially released which allows software developers to start working with the new code and updating their programs if necessary before the latest version of R is rolled out to general users. I know it is frustrating and a hassle when something that used to work stops (I currently work with Windows 7 x64, Windows XP x32, and Debian unstable---trying to keep all three up-to-date and working similarly keeps me on my toes and if half the things I've muttered under my breath about computers at 2am actually came to pass.), but also consider that the R core team already freely volunteer their time and (vast) skill to provide us this wonderful software. I do not think it is too much to ask that software developers and users be willing to put in some of their own time to update when there are changes and improvements to R that are, ultimately, benefiting us anyways. If it is truly too much bother and hassle for minor improvements, it may be better to only upgrade R versions at major releases (1, 2, 3, etc.). My school seems to have taken this approach and still has 1.8.1, I think, loaded on their lab computers. My $.02 (or$.05) Sincerely, Josh Joe Boyer
Re: [R] Semi-Regular Time Series with Missing Values
On Wed, Jan 19, 2011 at 1:10 PM, Adam Oliner oli...@gmail.com wrote: I don't seem to have that method: zts = as.ts.zoo(z) Error: could not find function as.ts.zoo I'm finding forum posts from people trying to use stl directly with zoo[reg] functions (despite the documentation specifying ts) but discovering that stl gives errors with NA entries. I encountered similar errors. Can anyone on this list confirm whether stl works with NA values? If so, could someone please point me to a working example? Normally S3 methods such as as.ts.zoo are not exported unless there is particular reason to access them directly. Rather one accesses them via their generic which dispatches the appropriate method based on the class of its first argument. That is if z is a zoo object then as.ts(z) dispatches as.ts.zoo. If you really want to see it you can do this zoo:::as.ts.zoo -- 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] Three-way interaction plot
Dear Stephanie, I'm not sure what kind of plot you have in mind, but you might take a look at the effects package, which can plot interactions for a variety of models. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ross, Stephanie Sent: January-19-11 10:10 AM To: r-help@R-project.org Subject: [R] Three-way interaction plot Hello All, I need to create a three-way interaction plot and I was wondering if anyone could recommend a package I could use to design these plots. Thank you! PHRI DISCLAIMER This information is directed in confidence solely to the person named above and may not otherwise be distributed, copied or disclosed. Therefore, this information should be considered strictly confidential. If you have received this email in error, please notify the sender immediately via a return email for further direction. Thank you for your assistance. [[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] Semi-Regular Time Series with Missing Values
On Wed, Jan 19, 2011 at 3:07 PM, Adam Oliner oli...@gmail.com wrote: This still does not give me the desired behavior: z = zoo(x, order.by=t, frequency=24) t = as.ts(z) ... inserts 23 NA values between every actual value. This is not correct; the original data has a frequency of 24 and doesn't need one forced upon it during coercion. z = zoo(x, order.by=t) t = as.ts(z) ... obviously doesn't give me a ts with frequency 24. Keep in mind that I'm trying to get a ts with frequency 24 so I can feed it to stl. I haven't yet found a sequence of operations that lets me do this. Any ideas? Its not clear what you are expecting but here is an example: library(zoo) z - zooreg(1001:1012, frequency = 4); z 1(1) 1(2) 1(3) 1(4) 2(1) 2(2) 2(3) 2(4) 3(1) 3(2) 3(3) 3(4) 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 frequency(z) [1] 4 tt - as.ts(z); tt Qtr1 Qtr2 Qtr3 Qtr4 1 1001 1002 1003 1004 2 1005 1006 1007 1008 3 1009 1010 1011 1012 frequency(tt) [1] 4 -- 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.
[R] problem with constructing bitmap
Dear R People: I'm building R-2.12.1 from scratch on a Windows XP machine. The make all recommended worked fine, but when I did the make in the bitmap directory, I got the following error: C:\R\R-2.12.1\src\gnuwin32\bitmapmake make make CC='gcc -std=gnu99' AR='ar' \ CFLAGS=-O3 -I../../../extra/zlib -DPNG_NO_MMX_CODE \ RANLIB=ranlib ZLIBLIB=../../../extra/zlib -C libpng \ -f scripts/makefile.mingw prefix=foo libpng.a make[2]: scripts/makefile.mingw: No such file or directory make[2]: *** No rule to make target `scripts/makefile.mingw'. Stop. make[1]: *** [buildpng] Error 2 make: *** [all] Error 2 Does this look familiar to anyone, please? Thanks in advance for any help. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@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] VarCorr
Cant you just save that column of values to an object stddev-VC[,2]#if it's the second column that has the values also I wouldn't save your model name in the same name as the command, when you have lmer-lmer(y~1+(1|sampfac)+(1|labfac)), may be best to have lmer.mod-lmer(y~1+(1|sampfac)+(1|labfac)) or something. Joe King 206-913-2912 j...@joepking.com Ad astra per aspera - Through hardships to the stars -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Stephanie Cooke Sent: Wednesday, January 19, 2011 11:33 AM To: r-help@r-project.org Subject: [R] VarCorr I have a loop that I would like to use to extract the stddev for each itteration so I can average the stddev for all the runs. It would be helpful to know how to extract the stddev for each run from the VarCorr. Thanks MCruns-1000 sighatlvec-rep(NA,MCruns) sighatbvec-rep(NA,MCruns) sighatevec-rep(NA,MCruns) for(mc in 1:MCruns) { samples-(sqrt(sigbsq)*rnorm(6)) labs-(sqrt(siglsq)*rnorm(2)) errors-(sqrt(sigesq)*rnorm(24)) y-errors+samples[sampfac]+labs[labfac] lmer-lmer(y~1+(1|sampfac)+(1|labfac)) print(VC-VarCorr(lmer)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problem with constructing bitmap: part of the problem
Hello again. Libpng version 1.5.0 does not have a scripts/makefile.mingw. However, Libpng version 1.2.44 does. That seems to be the snag. Presumably I should stick with the older version. Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@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] VarCorr
Is this what you want? attr(VarCorr(merobject)[[1]], stddev) Alternately, look at: getMethod(VarCorr, signature = mer) For what is happening behind the scenes and why I chose what I did to extract the standard deviations Cheers, Josh On Jan 19, 2011, at 11:32, Stephanie Cooke cooke.stepha...@gmail.com wrote: I have a loop that I would like to use to extract the stddev for each itteration so I can average the stddev for all the runs. It would be helpful to know how to extract the stddev for each run from the VarCorr. Thanks MCruns-1000 sighatlvec-rep(NA,MCruns) sighatbvec-rep(NA,MCruns) sighatevec-rep(NA,MCruns) for(mc in 1:MCruns) { samples-(sqrt(sigbsq)*rnorm(6)) labs-(sqrt(siglsq)*rnorm(2)) errors-(sqrt(sigesq)*rnorm(24)) y-errors+samples[sampfac]+labs[labfac] lmer-lmer(y~1+(1|sampfac)+(1|labfac)) print(VC-VarCorr(lmer)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Semi-Regular Time Series with Missing Values
This still does not give me the desired behavior: z = zoo(x, order.by=t, frequency=24) t = as.ts(z) ... inserts 23 NA values between every actual value. This is not correct; the original data has a frequency of 24 and doesn't need one forced upon it during coercion. z = zoo(x, order.by=t) t = as.ts(z) ... obviously doesn't give me a ts with frequency 24. Keep in mind that I'm trying to get a ts with frequency 24 so I can feed it to stl. I haven't yet found a sequence of operations that lets me do this. Any ideas? On Wed, Jan 19, 2011 at 12:00 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jan 19, 2011 at 1:10 PM, Adam Oliner oli...@gmail.com wrote: I don't seem to have that method: zts = as.ts.zoo(z) Error: could not find function as.ts.zoo I'm finding forum posts from people trying to use stl directly with zoo[reg] functions (despite the documentation specifying ts) but discovering that stl gives errors with NA entries. I encountered similar errors. Can anyone on this list confirm whether stl works with NA values? If so, could someone please point me to a working example? Normally S3 methods such as as.ts.zoo are not exported unless there is particular reason to access them directly. Rather one accesses them via their generic which dispatches the appropriate method based on the class of its first argument. That is if z is a zoo object then as.ts(z) dispatches as.ts.zoo. If you really want to see it you can do this zoo:::as.ts.zoo -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- - Adam J. Oliner [[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] R scheduling request
Thanks Greg, work i'm lost a { after function (). Alessandro 2011/1/19 Greg Snow greg.s...@imail.org: You could include a call to the source function that will read and run an R script (I have not tried this, but don't see any reason that it would not work). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Alessandro Oggioni [mailto:a.oggi...@ise.cnr.it] Sent: Tuesday, January 18, 2011 6:33 AM To: Greg Snow Cc: r-help Subject: Re: [R] R scheduling request Many thanks Greg! I try to use tcltk2 and tclTaskSchedule function but in argument expr is possible to insert a R script? Have you an example? Alessandro Il 17 gennaio 2011 22.02.51 UTC+1, Greg Snow greg.s...@imail.org ha scritto: You could write a batch file and then have your OS schedule to run R on the batch file whenever you want (see Rscript for one approach of running the batch). Inside of R you can use Sys.sleep to wait a certain amount of time before running the next command. If you load the tcltk2 package then you can use the tclTaskSchedule function. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Alessandro Oggioni Sent: Saturday, January 15, 2011 6:19 AM To: r-help Subject: [R] R scheduling request Dear all, I have used R.rps to produce a Google API chart (googleVis) with a data request in another server. But i don't understand how is possible to scheduling a request data to the server and after produce a update of the charts. Thanks in advance. Alessandro Oggioni __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Semi-Regular Time Series with Missing Values
Gabor, If you follow those steps on a series with missing values, the resulting tt will contain tons of new NAs. (See my original email and the call to zrt = as.ts(zr).) At any rate, I finally managed to finagle a ts with the correct frequency by coercing to ts _twice_ and specifying the frequency the second time: z = zoo(x, order.by=t) t = as.ts(z) tt = ts(t, frequency=24) frequency(tt) [1] 24 length(tt) [1] 92064 Unfortunately, the fundamental problem appears to be with stl, because I pass it the tt object above and get this error: stl(tt, s.window=periodic,na.action=F) Error in stl(tt, s.window = periodic, na.action = F) : series is not periodic or has less than two periods Of course, tt is periodic (see call to frequency() above) and has more than two periods (see corresponding call to length() above), so the error is nonsense. I finally found the following email from Jeff Ryan: https://stat.ethz.ch/pipermail/r-sig-finance/2008q4/003451.html * stl *function (x, s.window, s.degree = 0, t.window = NULL, t.degree = 1, x - na.action(as.ts(x)) if (is.matrix(x)) stop(only univariate series are allowed) n - length(x) period - frequency(x) if (period 2 || n = 2 * period) stop(series is not periodic or has less than two periods) Which will result in an object of freq=1, and thus throw an error. Which leaves me with a perfectly valid input to stl that is being converted, by stl, into an invalid input before giving me an error. Is there some way to make this work? Is this a bug? On Wed, Jan 19, 2011 at 12:31 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jan 19, 2011 at 3:07 PM, Adam Oliner oli...@gmail.com wrote: This still does not give me the desired behavior: z = zoo(x, order.by=t, frequency=24) t = as.ts(z) ... inserts 23 NA values between every actual value. This is not correct; the original data has a frequency of 24 and doesn't need one forced upon it during coercion. z = zoo(x, order.by=t) t = as.ts(z) ... obviously doesn't give me a ts with frequency 24. Keep in mind that I'm trying to get a ts with frequency 24 so I can feed it to stl. I haven't yet found a sequence of operations that lets me do this. Any ideas? Its not clear what you are expecting but here is an example: library(zoo) z - zooreg(1001:1012, frequency = 4); z 1(1) 1(2) 1(3) 1(4) 2(1) 2(2) 2(3) 2(4) 3(1) 3(2) 3(3) 3(4) 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 frequency(z) [1] 4 tt - as.ts(z); tt Qtr1 Qtr2 Qtr3 Qtr4 1 1001 1002 1003 1004 2 1005 1006 1007 1008 3 1009 1010 1011 1012 frequency(tt) [1] 4 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- - Adam J. Oliner [[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] Semi-Regular Time Series with Missing Values
On Wed, Jan 19, 2011 at 4:17 PM, Adam Oliner oli...@gmail.com wrote: Gabor, If you follow those steps on a series with missing values, the resulting tt will contain tons of new NAs. (See my original email and the call to zrt = zoo and zooreg classes handle series which may not be regularly spaced whereas ts only handles regularly spaced series so the series necessarily must be filled with NAs if you convert it from an irregularly spaced one to a regularly spaced one. -- 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] ggplot2, geom_hline and facet_grid
Hi Still having problems in that when I use geom_hline and facet_grid together I get two extra empty panels A reproducible example can be found at: https://gist.github.com/786894 Sandy Small From: h.wick...@gmail.com [h.wick...@gmail.com] On Behalf Of Hadley Wickham [had...@rice.edu] Sent: 19 January 2011 15:11 To: Small Sandy (NHS Greater Glasgow Clyde) Cc: r-help@r-project.org Subject: Re: [R] ggplot2, geom_hline and facet_grid Hi Sandy, It's difficult to know what's going wrong without a small reproducible example (https://github.com/hadley/devtools/wiki/Reproducibility) - could you please provide one? You might also have better luck with an email directly to the ggplot2 mailing list. Hadley On Wed, Jan 19, 2011 at 2:57 AM, Sandy Small sandy.sm...@nhs.net wrote: Having upgraded to R version 2.12.1 I still have the same problem: The combination of facet_grid and geom_hline produce (for me) 4 panels of which two are empty of any data or lines (labelled 1 and 2). Removing either the facet_grid or the geom_hline gives me the result I would then expect. I have tried forcing the rhythm to be a factor Anyone have any ideas? Sandy Dennis Murphy wrote: Hi: The attached plot comes from the following code: g - ggplot(data =f, aes(x = (variable_time + fixed_time)/2, y variable_time - fixed_time)) g + geom_point() + geom_hline(yintercept =) + facet_grid(ecd_rhythm ~ .) Is this what you were expecting? sessionInfo() R version 2.12.1 Patched (2010-12-18 r53869) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=glish_United States.1252 [2] LC_CTYPE=glish_United States.1252 [3] LC_MONETARY=glish_United States.1252 [4] LC_NUMERIC=nbsp; [5] LC_TIME=glish_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets grid [8] methods base other attached packages: [1] data.table_1.5.1 doBy_4.2.2 R2HTML_2.2 contrast_0.13 [5] Design_2.3-0 Hmisc_3.8-3 survival_2.36-2 sos_1.3-0 [9] brew_1.0-4 lattice_0.19-17 ggplot2_0.8.9proto_0.3-8 [13] reshape_0.8.3plyr_1.4 loaded via a namespace (and not attached): [1] cluster_1.13.2 digest_0.4.2 Matrix_0.999375-46 reshape2_1.1 [5] stringr_0.4tools_2.12.1 HTH, Dennis On Tue, Jan 18, 2011 at 1:46 AM, Small Sandy (NHS Greater Glasgow Clyde) sandy.sm...@nhs.net ailto:sandy.sm...@nhs.net%22 wrote: Hi I have a long data set on which I want to do Bland-Altman style plots for each rhythm type Using ggplot2, when I use geom_hline with facet_grid I get an extra set of empty panels. I can't get it to do it with the Diamonds data supplied with the package so here is a (much abbreviated) example: lvexs cvd_basestudy ecd_rhythm fixed_time variable_time 1 CBP05J02 AF30.9000 29.4225 2 CBP05J02 AF33.1700 32.0350 3 CBP05J02 AF32.5700 30.2775 4 CBP05J02 AF32.0550 33.7275 5 CBP05J02 SINUS30.9175 28.3475 6 CBP05J02 SINUS30.5725 29.7450 7 CBP05J02 SINUS33. 31.1550 9 CBP05J02 SINUS31.8350 30.7000 10 CBP05J02 SINUS34.0450 33.4800 11 CBP05J02 SINUS31.3975 29.8150 qplot((variable_time + fixed_time)/2, variable_time - fixed_time, data=exs) + facet_grid(ecd_rhythm ~ .) + geom_hline(yintercept=0) If I take out the geom_hline I get the plots I would expect. It doesn't seem to make any difference if I get the mean and difference separately. Can anyone explain this and tell me how to avoid it (and why does it work with the Diamonds data set? Any help much appreciated - thanks. Sandy Sandy Small Clinical Physicist NHS Forth Valley and NHS Greater Glasgow and Clyde This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ This message may contain confidential information. If you are not the intended recipient please inform
Re: [R] problem with constructing bitmap
I suspect you have libpng 1.5.0 (assuming you installed libpng at all). So 1) That version has a CERT advisory, and should not be used. 1.5.1 is due tomorrow. 2) R 2.12.1 cannot work with future versions of external software. libpng 1.4.5 does work, but not 1.5.x. (And BTW, questions about buldiing R from sources are more likely to be noticed on R-devel.) On Wed, 19 Jan 2011, Erin Hodgess wrote: Dear R People: I'm building R-2.12.1 from scratch on a Windows XP machine. The make all recommended worked fine, but when I did the make in the bitmap directory, I got the following error: C:\R\R-2.12.1\src\gnuwin32\bitmapmake make make CC='gcc -std=gnu99' AR='ar' \ CFLAGS=-O3 -I../../../extra/zlib -DPNG_NO_MMX_CODE \ RANLIB=ranlib ZLIBLIB=../../../extra/zlib -C libpng \ -f scripts/makefile.mingw prefix=foo libpng.a make[2]: scripts/makefile.mingw: No such file or directory make[2]: *** No rule to make target `scripts/makefile.mingw'. Stop. make[1]: *** [buildpng] Error 2 make: *** [all] Error 2 Does this look familiar to anyone, please? Thanks in advance for any help. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot question
Hi all, I had a weird problem with xyplot and I am wondering if anyone can help me figure out what's wrong here. Basically if I call xyplot() inside a function and I call quartz() after, then the previous xyplot() does not do anything. A short demo of the issue is like this: library(lattice) plot.trends - function() { mat - data.frame(cbind(rnorm(100), rnorm(100))) names(mat) - c(x, y) quartz() xyplot(y ~ x, data=mat) quartz() # plotting works if this line is removed } plot.trends() * if I run this as is, the xyplot() doesn't do anything, I only see 2 empty quartz window * replacing quartz() with X11() doesn't help. * if the content of the function is copied and run directly then it works fine. * if the second quartz() statement is removed then it also works. Here is my system info. * R 2.12.0 * R.app GUI 1.35 (5632) i386-apple-darwin9.8.0 * lattice_0.19-17 any suggestions? Thanks in advance! Saiwing Yeung __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Semi-Regular Time Series with Missing Values
On Wed, Jan 19, 2011 at 4:27 PM, Adam Oliner oli...@gmail.com wrote: My series was regularly spaced, it simply contained missing values. I don't see why the new values were added. Besides, my previous email showed exactly how to convert a zoo object with Please provide a minimal self-contained reproducible example (as per last line on every r-help message) and explain what you were expecting that is different than what you got and we may be able to say more. -- 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] Help with logistic model with random effects in R
LAURA WEIR 0611792W at student.gla.ac.uk writes: Hello everyone, I'm quite new to R and am trying to run a logistic model to look at how various measures of boldness in individual animals influences probability of capture, however I also want to include random effects and I'm not sure how to construct a model that incorporates both of these things. Data was collected from 6 different groups of 6 individuals with 10 replicates for each group. Whether an individual was caught in a trial or not was called Catchability and the outcome is binomial (caught = 1, not caught = 0). Catchability is my response variable that I want to see if I can explain by the other variables. Individual and Group would be my random effects. I have already installed lme4 but not sure how to code for the model I need, can anyone offer any help please? The column headings in my data table are as follows. [1] Trial Group Individual Mark [5] Catchability Mboldness1 Mboldness2 Nboldness1 [9] Nboldness2 Standardlength This is the string of my data: str(data) 'data.frame': 36 obs. of 10 variables: $ Trial : int 1 2 3 4 5 6 7 8 9 10 ... $ Group : int 1 1 1 1 1 1 2 2 2 2 ... $ Individual: int 1 2 3 4 5 6 7 8 9 10 ... $ Mark : Factor w/ 8 levels - O, - P,..: 8 2 4 6 3 1 6 3 1 5 ... $ Catchability : int 1 1 1 1 0 1 1 1 1 1 ... $ Mboldness1: int 7 10 0 11 15 5 15 4 15 1 ... $ Mboldness2: int 1 270 600 1 10 203 10 230 1 580 ... $ Nboldness1: int 0 0 0 0 0 0 1 0 2 0 ... $ Nboldness2: int 270 110 50 50 90 70 130 90 260 220 ... $ Standardlength: num 40.5 37.4 38.6 41.1 39.1 40.5 50.2 60.3 53.9 55 ... I'm a little confused about your experimental design. You say you have 10 replicates per group, but I only see 36 observations in your data set -- from your description I would have expected 360? If you had 10 replicates per group I would say should do something like glmer(Catchability~[fixed effect predictors]+(1|Group/Individual), family=binomial,data=data) A couple of other points: * it's considered bad practice to name your data set 'data' (which is also the name of a built-in R function). Usually it's OK, but occasionally it could cause problems. * A rule of thumb is that you should not try to fit a model with more than k=N/10 parameters, where for binary data 'N' is the minimum of (number of successes, number of failures). * 6 groups is at the lower edge of feasibility for fitting a random effect -- you may find that glmer estimates the group-level variance as zero. (Don't panic.) I would suggest that you send follow-ups to r-sig-mixed-mod...@r-project.org and possibly take a look at http://glmm.wikidot.com/faq cheers 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.
Re: [R] xyplot question
On 11-01-19 4:54 PM, Saiwing Yeung wrote: Hi all, I had a weird problem with xyplot and I am wondering if anyone can help me figure out what's wrong here. Basically if I call xyplot() inside a function and I call quartz() after, then the previous xyplot() does not do anything. A short demo of the issue is like this: library(lattice) plot.trends- function() { mat- data.frame(cbind(rnorm(100), rnorm(100))) names(mat)- c(x, y) quartz() xyplot(y ~ x, data=mat) quartz() # plotting works if this line is removed } plot.trends() This is a version of FAQ 7.22: you need to tell R to print lattice graphics. Without the next statement, the result would be auto-printed. Duncan Murdoch * if I run this as is, the xyplot() doesn't do anything, I only see 2 empty quartz window * replacing quartz() with X11() doesn't help. * if the content of the function is copied and run directly then it works fine. * if the second quartz() statement is removed then it also works. Here is my system info. * R 2.12.0 * R.app GUI 1.35 (5632) i386-apple-darwin9.8.0 * lattice_0.19-17 any suggestions? Thanks in advance! Saiwing Yeung __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] spacing of color key in filled.contour
Hi all I'm plotting colored contour maps using filled.contour. My levels are very unevenly spaced, with, say, high resolution in the small numbers but ranges that can be an order of magnitude or two larger in absolute value compared to where the action takes place. Aside from transforming the data, is there a way to control the color spacing in the key to the right of the map? Right now I get most of the key length taken up by a couple of colors and the rest all squeezed into thin slices, which also creates a problem with the fourth axis labels getting drawn on top of one another. thank you very much in advance Claudia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2, geom_hline and facet_grid
Hi Sandy: I can reproduce your problem given the data provided. When I change ecd_rhythm from character to factor, it works as you intended. str(lvefeg) List of 4 ### Interesting... $ cvd_basestudy: chr [1:10] CBP05J02 CBP05J02 CBP05J02 CBP05J02 ... $ ecd_rhythm : chr [1:10] AF AF AF AF ... $ fixed_time : num [1:10] 30.9 33.2 32.6 32.1 30.9 ... $ variable_time: num [1:10] 29.4 32 30.3 33.7 28.3 ... - attr(*, row.names)= int [1:10] 1 2 3 4 5 6 7 9 10 11 class(lvefeg) [1] cast_dfdata.frame lvefeg$ecd_rhythm - factor(lvefeg$ecd_rhythm) p - qplot((variable_time + fixed_time) /2 , variable_time - fixed_time, data = lvefeg, geom='point') p p + facet_grid(ecd_rhythm ~ .) + geom_hline(yintercept=0) Does that work on your end? (And thank you for the reproducible example. Using dput() allows us to see what you see, which is very helpful.) HTH, Dennis On Wed, Jan 19, 2011 at 1:30 PM, Small Sandy (NHS Greater Glasgow Clyde) sandy.sm...@nhs.net wrote: Hi Still having problems in that when I use geom_hline and facet_grid together I get two extra empty panels A reproducible example can be found at: https://gist.github.com/786894 Sandy Small From: h.wick...@gmail.com [h.wick...@gmail.com] On Behalf Of Hadley Wickham [had...@rice.edu] Sent: 19 January 2011 15:11 To: Small Sandy (NHS Greater Glasgow Clyde) Cc: r-help@r-project.org Subject: Re: [R] ggplot2, geom_hline and facet_grid Hi Sandy, It's difficult to know what's going wrong without a small reproducible example (https://github.com/hadley/devtools/wiki/Reproducibility) - could you please provide one? You might also have better luck with an email directly to the ggplot2 mailing list. Hadley On Wed, Jan 19, 2011 at 2:57 AM, Sandy Small sandy.sm...@nhs.net wrote: Having upgraded to R version 2.12.1 I still have the same problem: The combination of facet_grid and geom_hline produce (for me) 4 panels of which two are empty of any data or lines (labelled 1 and 2). Removing either the facet_grid or the geom_hline gives me the result I would then expect. I have tried forcing the rhythm to be a factor Anyone have any ideas? Sandy Dennis Murphy wrote: Hi: The attached plot comes from the following code: g - ggplot(data =f, aes(x = (variable_time + fixed_time)/2, y variable_time - fixed_time)) g + geom_point() + geom_hline(yintercept =) + facet_grid(ecd_rhythm ~ .) Is this what you were expecting? sessionInfo() R version 2.12.1 Patched (2010-12-18 r53869) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=glish_United States.1252 [2] LC_CTYPE=glish_United States.1252 [3] LC_MONETARY=glish_United States.1252 [4] LC_NUMERIC=nbsp; [5] LC_TIME=glish_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets grid [8] methods base other attached packages: [1] data.table_1.5.1 doBy_4.2.2 R2HTML_2.2 contrast_0.13 [5] Design_2.3-0 Hmisc_3.8-3 survival_2.36-2 sos_1.3-0 [9] brew_1.0-4 lattice_0.19-17 ggplot2_0.8.9proto_0.3-8 [13] reshape_0.8.3plyr_1.4 loaded via a namespace (and not attached): [1] cluster_1.13.2 digest_0.4.2 Matrix_0.999375-46 reshape2_1.1 [5] stringr_0.4tools_2.12.1 HTH, Dennis On Tue, Jan 18, 2011 at 1:46 AM, Small Sandy (NHS Greater Glasgow Clyde) sandy.sm...@nhs.net ailto:sandy.sm...@nhs.netailto%3asandy.sm...@nhs.net%22 wrote: Hi I have a long data set on which I want to do Bland-Altman style plots for each rhythm type Using ggplot2, when I use geom_hline with facet_grid I get an extra set of empty panels. I can't get it to do it with the Diamonds data supplied with the package so here is a (much abbreviated) example: lvexs cvd_basestudy ecd_rhythm fixed_time variable_time 1 CBP05J02 AF30.9000 29.4225 2 CBP05J02 AF33.1700 32.0350 3 CBP05J02 AF32.5700 30.2775 4 CBP05J02 AF32.0550 33.7275 5 CBP05J02 SINUS30.9175 28.3475 6 CBP05J02 SINUS30.5725 29.7450 7 CBP05J02 SINUS33. 31.1550 9 CBP05J02 SINUS31.8350 30.7000 10 CBP05J02 SINUS34.0450 33.4800 11 CBP05J02 SINUS31.3975 29.8150 qplot((variable_time + fixed_time)/2, variable_time - fixed_time, data=exs) + facet_grid(ecd_rhythm ~ .) + geom_hline(yintercept=0) If I take out the geom_hline I get the plots I would expect. It doesn't seem to make any difference if I get the mean and difference
[R] MCMC object indexing
I have an mcmc object and I'm trying to plot the quantiles of the variables - and not as a function of the iterations as in cumuplot. I cannot seem to find the right combination of indexing to access the variables; after which I'm sure I can plot all the statistics I could hope for. Any hints for accessing the mcmc object would be appreciated. =Dave [[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] spatstat theoretical values from inhomogeneous Poisson models
Hello, I am using the Kinhom function to plot envelopes from my fitted inhomogeneous models in spatstat. But the results I obtain do not have a theoretical value (theo). They only give me the hi, lo, r and mmean values but no theo. Please can anyone help? Mike. [[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] Semi-Regular Time Series with Missing Values
My series was regularly spaced, it simply contained missing values. I don't see why the new values were added. Besides, my previous email showed exactly how to convert a zoo object with missing values into a ts object with missing values and a frequency other than 1, so I'm not sure what you mean: z = zoo(x, order.by=t) t = as.ts(z) frequency(t) [1] 1 length(t) [1] 92064 tt = ts(t, frequency=24) frequency(tt) [1] 24 length(tt) [1] 92064 On Wed, Jan 19, 2011 at 1:20 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jan 19, 2011 at 4:17 PM, Adam Oliner oli...@gmail.com wrote: Gabor, If you follow those steps on a series with missing values, the resulting tt will contain tons of new NAs. (See my original email and the call to zrt = zoo and zooreg classes handle series which may not be regularly spaced whereas ts only handles regularly spaced series so the series necessarily must be filled with NAs if you convert it from an irregularly spaced one to a regularly spaced one. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- - Adam J. Oliner [[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] Semi-Regular Time Series with Missing Values
The objective is to get the stl calls to work without making up values for the NAs: library(zoo) data = c(50, 32, 22, 13, 14, 6, 12, 3, 6, 21, NA, NA, 15, 13, 17, 9, 11, 34, 63) dataz = zoo(data, 1:length(data)) t = as.ts(dataz) datat = as.ts(dataz) datatt = ts(t, frequency=2) frequency(datatt) length(datatt) # these all give errors stl(datatt, s.window=per) # this next error is especially bizarre to me, because datatt is periodic with more than two periods stl(datatt, s.window=per, na.action=F) stl(datatt, s.window=per, na.action=na.omit) stl(datatt, s.window=per, na.action=na.pass) stl(datatt, s.window=per, na.action=na.exclude) stl(dataz, s.window=per, na.action=F) stl(datat, s.window=per, na.action=F) I was expecting at least one of the stl calls to work, because stl claims to require a ts object with a frequency greater than one and at least two periods (which I gave it) and it claims to handle NA values. On Wed, Jan 19, 2011 at 1:59 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jan 19, 2011 at 4:27 PM, Adam Oliner oli...@gmail.com wrote: My series was regularly spaced, it simply contained missing values. I don't see why the new values were added. Besides, my previous email showed exactly how to convert a zoo object with Please provide a minimal self-contained reproducible example (as per last line on every r-help message) and explain what you were expecting that is different than what you got and we may be able to say more. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- - Adam J. Oliner [[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] xyplot question
This is a version of FAQ 7.22: you need to tell R to print lattice graphics. Without the next statement, the result would be auto-printed. Duncan Murdoch That fixed it. Thank you again. Sorry for not reading the FAQ. Saiwing __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Semi-Regular Time Series with Missing Values
On Wed, Jan 19, 2011 at 5:21 PM, Adam Oliner oli...@gmail.com wrote: The objective is to get the stl calls to work without making up values for the NAs: library(zoo) data = c(50, 32, 22, 13, 14, 6, 12, 3, 6, 21, NA, NA, 15, 13, 17, 9, 11, 34, 63) dataz = zoo(data, 1:length(data)) t = as.ts(dataz) datat = as.ts(dataz) datatt = ts(t, frequency=2) frequency(datatt) length(datatt) # these all give errors stl(datatt, s.window=per) # this next error is especially bizarre to me, because datatt is periodic with more than two periods stl(datatt, s.window=per, na.action=F) stl(datatt, s.window=per, na.action=na.omit) stl(datatt, s.window=per, na.action=na.pass) stl(datatt, s.window=per, na.action=na.exclude) stl(dataz, s.window=per, na.action=F) stl(datat, s.window=per, na.action=F) I was expecting at least one of the stl calls to work, because stl claims to require a ts object with a frequency greater than one and at least two periods (which I gave it) and it claims to handle NA values. I think what you want is: library(zoo) library(zoo) data - c(50, 32, 22, 13, 14, 6, 12, 3, 6, 21, NA, NA, 15, 13, 17, 9, 11, 34, 63) z - zooreg(data, frequency = 2) stl(z) or equivalently tt - ts(data, frequency = 2) stl(tt) however stl does not support series with NAs so that can't work with your data and specifying na.action won't help since that is equivalent to stl(na.action(as.ts(z))). Also note that na.action's value is a function and na.action = F is illegal unless you have a function called F in your workspace. These work in so far as they give an answer but whether they are acceptable is up to you: stl(z[1:01], per) stl(z[13:19], per) stl(na.approx(z), per) -- 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] function of probability for normal distribution
Dear Greg Snow, I'm a biologist trying to write a mathematical formula for a doubly truncated normal distribution to be used in the language R. I realise this is simple stuff for a mathematician but I'm stumped. Wikipedia gives what seems a fairly simple formula - with function = maths with mean and standard deviation - but also phi - WHAT IS PHI !!?? - especially how do I write this in R and why is the top phi in italics ?? Hoping you can help. Yours sincerely, Jeremy Clark -- View this message in context: http://r.789695.n4.nabble.com/Re-R-function-for-Probabilities-for-the-standard-normal-distribution-tp903639p3225457.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] Using subset to filter data table
Thank you Santosh. I am so new to R that I don't even have droplevels: 1 tcc2 = droplevels(tcc) Error: could not find function droplevels I looked up ?droplevels: 1 ?droplevels No documentation for 'droplevels' in specified packages and libraries: you could try '??droplevels' 1 ??droplevels Help files with alias or concept or title matching droplevels using fuzzy matching: gdata::drop.levels Drop unused factor levels Type '?PKG::FOO' to inspect entry 'PKG::FOO TITLE'. However, droplevels is in the base package apparently, yet I haven't got it. Can anyone explain this to me? 1 R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 10.1 year 2009 month 12 day14 svn rev50720 language R version.string R version 2.10.1 (2009-12-14) Ben. On 19 January 2011 19:27, Santosh Srinivas santosh.srini...@gmail.comwrote: tcc.new2 - droplevels(tcc.new) [[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] Semi-Regular Time Series with Missing Values
Gabor, On Wed, Jan 19, 2011 at 3:36 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: stl does not support series with NAs Thank you. This is what I needed to know. Cheers, -- - Adam J. Oliner [[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] Semi-Regular Time Series with Missing Values
Whoops, fixed a typo: library(zoo) data = c(50, 32, 22, 13, 14, 6, 12, 3, 6, 21, NA, NA, 15, 13, 17, 9, 11, 34, 63) dataz = zoo(data, 1:length(data)) datat = as.ts(dataz) datatt = ts(datat, frequency=2) frequency(datatt) length(datatt) # these all give errors stl(datatt, s.window=per) # this next error is especially bizarre to me, because datatt is periodic with more than two periods stl(datatt, s.window=per, na.action=F) stl(datatt, s.window=per, na.action=na.omit) stl(datatt, s.window=per, na.action=na.pass) stl(datatt, s.window=per, na.action=na.exclude) stl(dataz, s.window=per, na.action=F) stl(datat, s.window=per, na.action=F) On Wed, Jan 19, 2011 at 2:21 PM, Adam Oliner oli...@gmail.com wrote: The objective is to get the stl calls to work without making up values for the NAs: library(zoo) data = c(50, 32, 22, 13, 14, 6, 12, 3, 6, 21, NA, NA, 15, 13, 17, 9, 11, 34, 63) dataz = zoo(data, 1:length(data)) t = as.ts(dataz) datat = as.ts(dataz) datatt = ts(t, frequency=2) frequency(datatt) length(datatt) # these all give errors stl(datatt, s.window=per) # this next error is especially bizarre to me, because datatt is periodic with more than two periods stl(datatt, s.window=per, na.action=F) stl(datatt, s.window=per, na.action=na.omit) stl(datatt, s.window=per, na.action=na.pass) stl(datatt, s.window=per, na.action=na.exclude) stl(dataz, s.window=per, na.action=F) stl(datat, s.window=per, na.action=F) I was expecting at least one of the stl calls to work, because stl claims to require a ts object with a frequency greater than one and at least two periods (which I gave it) and it claims to handle NA values. On Wed, Jan 19, 2011 at 1:59 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jan 19, 2011 at 4:27 PM, Adam Oliner oli...@gmail.com wrote: My series was regularly spaced, it simply contained missing values. I don't see why the new values were added. Besides, my previous email showed exactly how to convert a zoo object with Please provide a minimal self-contained reproducible example (as per last line on every r-help message) and explain what you were expecting that is different than what you got and we may be able to say more. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- - Adam J. Oliner -- - Adam J. Oliner [[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 of probability for normal distribution
On Wed, 19 Jan 2011, JClark wrote: Dear Greg Snow, I'm a biologist trying to write a mathematical formula for a doubly truncated normal distribution to be used in the language R. I realise this is simple stuff for a mathematician but I'm stumped. Wikipedia gives what seems a fairly simple formula - with function = maths with mean and standard deviation - but also phi - WHAT IS PHI !!?? - On http://en.wikipedia.org/wiki/Truncated_normal_distribution it says (by copy-and-paste) The density function involves \scriptstyle{\phi(\cdot)} \ , which is the probability density function of the standard normal distribution and \scriptstyle{\Phi(\cdot)} \ , its cumulative distribution function. There are some links there that you can follow to get up to speed. especially how do I write this in R and why is the top phi in italics ?? Hmmm. Try the posting guide's suggestions. This seems to help: ?distribution [stuff deleted] For the normal distribution see dnorm. and ?dnorm [stuff deleted] dnorm gives the density, pnorm gives the distribution function, qnorm gives the quantile function, and rnorm generates random deviates. so match up 'density' and 'distribution function' in the ?dnorm page and the wiki page and you should be able to put it together. (FWIW, ?density and ??density are not so helpful.) BTW \frac{\frac{1}{\sigma}\phi(\frac{x - \mu}{\sigma})} (copy and pasted from the wiki page) can be rendered as dnorm(x , mu, sigma ) in R. HTH, Chuck Hoping you can help. Yours sincerely, Jeremy Clark -- View this message in context: http://r.789695.n4.nabble.com/Re-R-function-for-Probabilities-for-the-standard-normal-distribution-tp903639p3225457.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. Charles C. BerryDept of Family/Preventive Medicine cbe...@tajo.ucsd.eduUC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 of probability for normal distribution
On Jan 19, 2011, at 6:03 PM, JClark wrote: Dear Greg Snow, I'm a biologist trying to write a mathematical formula for a doubly truncated normal distribution to be used in the language R. I realise this is simple stuff for a mathematician but I'm stumped. Wikipedia gives what seems a fairly simple formula - with function = maths with mean and standard deviation - but also phi - WHAT IS PHI !!?? - Capital phi is the cdf of the Normal distribution and lowercase phi is the density (the cdf's derivative). You can see fairly standard usage in the Definition and Cumulative distribution function sections of the Wikipedia page. especially how do I write this in R You will need these: ?pnrom ?dnorm and why is the top phi in italics ?? You are being unreasonably vague here. You are apparently looking at something. We are looking at a plaintext message. Perhaps you are (mis)calling a lowercase phi as italic? Maybe you should read the Posting Guide and the items it links to regarding how to ask a good question?? -- 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] circular reference lines in splom
Hello everyone, I'm stumped. I'd like to create a scatterplot matrix with circular reference lines. Here is an example in 2d: library(ellipse) set.seed(1) dat - matrix(rnorm(300), ncol = 3) colnames(dat) - c(X1, X2, X3) dat - as.data.frame(dat) grps - factor(rep(letters[1:4], 25)) panel.circ - function(x, y, ...) { circ1 - ellipse(diag(rep(1, 2)), t = 1) panel.xyplot(circ1[,1], circ1[,2], type = l, lty = 2) circ2 - ellipse(diag(rep(1, 2)), t = 2) panel.xyplot(circ2[,1], circ2[,2], type = l, lty = 2) panel.xyplot(x, y) } xyplot(X2 ~ X1, data = dat, panel = panel.circ, aspect = 1) I'd like to to the sample with splom, but with groups. My latest attempt: panel.circ2 - function(x, y, groups, ...) { circ1 - ellipse(diag(rep(1, 2)), t = 1) panel.xyplot(circ1[,1], circ1[,2], type = l, lty = 2) circ2 - ellipse(diag(rep(1, 2)), t = 2) panel.xyplot(circ2[,1], circ2[,2], type = l, lty = 2) panel.xyplot(x, y, type = p, groups) } splom(~dat, panel = panel.superpose, panel.groups = panel.circ2) produces nothing but warnings: warnings() Warning messages: 1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL' It does not appear to me that panel.circ2 is even being called. Thanks, Max sessionInfo() R version 2.11.1 Patched (2010-09-30 r53356) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.19-11 ellipse_0.3-5 loaded via a namespace (and not attached): [1] grid_2.11.1 tools_2.11.1 -- 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.
[R] Question on RData and Rhistory extentions
Hi, It seems simple but I could not find the solution on the R site. I can't save properly .RData and .Rhistory in Windows 7 folders. I get files with no extension. Thanks in advance for your help. JP Jean-Philippe Puyravaud 9A Frederic Osanam Street Colas Nagar Puducherry 605001 E-mail: mailto:jp.puyrav...@gmail.com jp.puyrav...@gmail.com Phone: 91-413-23 53 944 Mobile: 91-944 249 50 89 [[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] Using subset to filter data table
Thank you Santosh. I am so new to R that I don't even have droplevels: 1 tcc2 = droplevels(tcc) Error: could not find function droplevels I looked up ?droplevels: 1 ?droplevels No documentation for 'droplevels' in specified packages and libraries: you could try '??droplevels' 1 ??droplevels Help files with alias or concept or title matching droplevels using fuzzy matching: gdata::drop.levels Drop unused factor levels Type '?PKG::FOO' to inspect entry 'PKG::FOO TITLE'. However, droplevels is in the base package apparently, yet I haven't got it. Can anyone explain this to me? 1 R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 10.1 year 2009 month 12 day14 svn rev50720 language R version.string R version 2.10.1 (2009-12-14) Ben. On 19 January 2011 19:27, Santosh Srinivas santosh.srini...@gmail.comwrote: tcc.new2 - droplevels(tcc.new) [[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] Using subset to filter data table
Ben - droplevels was introduced in R version 2.12.0. Since you are running version 2.10.1, it won't be available. You might want to upgrade to a more recent version. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Thu, 20 Jan 2011, Ben Harrison wrote: Thank you Santosh. I am so new to R that I don't even have droplevels: 1 tcc2 = droplevels(tcc) Error: could not find function droplevels I looked up ?droplevels: 1 ?droplevels No documentation for 'droplevels' in specified packages and libraries: you could try '??droplevels' 1 ??droplevels Help files with alias or concept or title matching ?droplevels? using fuzzy matching: gdata::drop.levels Drop unused factor levels Type '?PKG::FOO' to inspect entry 'PKG::FOO TITLE'. However, droplevels is in the base package apparently, yet I haven't got it. Can anyone explain this to me? 1 R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 10.1 year 2009 month 12 day14 svn rev50720 language R version.string R version 2.10.1 (2009-12-14) Ben. On 19 January 2011 19:27, Santosh Srinivas santosh.srini...@gmail.comwrote: tcc.new2 - droplevels(tcc.new) [[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] Question on RData and Rhistory extentions
I think you get files with extensions, but you have not told Windows to show them to you. Adjust your file display settings in a file manager window. Jean-Philippe Puyravaud jp.puyrav...@gmail.com wrote: Hi, It seems simple but I could not find the solution on the R site. I can't save properly .RData and .Rhistory in Windows 7 folders. I get files with no extension. Thanks in advance for your help. JP Jean-Philippe Puyravaud 9A Frederic Osanam Street Colas Nagar Puducherry 605001 E-mail: mailto:jp.puyrav...@gmail.com jp.puyrav...@gmail.com Phone: 91-413-23 53 944 Mobile: 91-944 249 50 89 [[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. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.