[R] prediction based on conditional logistic regression clogit
Hi, I am using clogit() from survival package to do conditional logistic regression. I also need to make prediction on an independent dataset to calculate predicted probability. Here is an example: > dat <- data.frame(set=rep(1:50,each=3), status=rep(c(1,0,0),50), > x1=rnorm(150,5,1), x2=rnorm(150,7,1.5)) > dat.test <- data.frame(set=rep(1:30,each=3), status=rep(c(1,0,0),30), > x1=rnorm(90,5,1), x2=rnorm(90,7,1.5)) > fit<-clogit(status~x1+x2+strata(set),dat) > predict(fit,newdata=dat.test,type='expected') Error in Surv(rep(1, 150L), status) : Time and status are different lengths Can anyone suggest what's wrong here? Thanks! John [[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 with SEM package - model significance
Dear all, I used "sem" function from the package SEM to fit a model. However, I cannot say if the model is correspondent to the data or not (chisquare test). I used the commands: model1 <- specifyModel() estadio -> compflora, a1, NA estadio -> compfauna, a2, NA estadio -> interacoesobs, a3, NA compflora -> compfauna, b1, NA compflora -> interacoesobs, b2, NA compfauna -> interacoesobs, c1, NA estadio <-> estadio, e1, NA compflora <-> compflora, e2, NA compfauna <-> compfauna, e3, NA interacoesobs <-> interacoesobs, e4, NA sem1 <- sem(model1, cov.matrix, length(samples)) summary(sem1) and I got the result: Model Chisquare = -2.873188e-13 Df = 0 Pr(>Chisq) = NA AIC = 20 BIC = -2.873188e-13 Normalized Residuals Min. 1st Qu.Median Mean 3rd Qu. Max. 0.000e+00 0.000e+00 2.957e-16 3.193e-16 5.044e-16 8.141e-16 R-square for Endogenous Variables compflora compfauna interacoesobs 0.0657 0.10560.2319 Parameter Estimates Estimate Std Errorz value Pr(>|z|) a1 3.027344e-01 1.665395e-01 1.81779316 6.909575e-02 compflora <--- estadio a2 2.189427e-01 1.767404e-01 1.23878105 2.154266e-01 compfauna <--- estadio a3 7.314192e-03 1.063613e-01 0.06876742 9.451748e-01 interacoesobs <--- estadio b1 2.422906e-01 1.496290e-01 1.61927587 1.053879e-01 compfauna <--- compflora b2 3.029933e-01 9.104901e-02 3.32780446 8.753328e-04 interacoesobs <--- compflora c1 4.863368e-02 8.638177e-02 0.56300857 5.734290e-01 interacoesobs <--- compfauna e1 6.918133e+04 1.427102e+04 4.84767986 1.249138e-06 estadio <--> estadio e2 9.018230e+04 1.860319e+04 4.84767986 1.249138e-06 compflora <--> compflora e3 9.489661e+04 1.957568e+04 4.84767986 1.249138e-06 compfauna <--> compfauna e4 3.328072e+04 6.865289e+03 4.84767986 1.249138e-06 interacoesobs <--> interacoesobs Iterations = 0 I understand the results, but I do not know how to interpret the first line that tells me about the model: Model Chisquare = -2.873188e-13 Df = 0 Pr(>Chisq) = NA How can DF be zero, if the number of observations I used in sem funcition was 48 and I have only 4 variables? What is the p value? Thanks in advance. Bernardo Niebuhr [[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] abline; setting plot limits
On 16/06/14 12:35, Jim Lemon wrote: On Mon, 16 Jun 2014 08:54:41 AM Rolf Turner wrote: On 15/06/14 15:34, Paul Rydelek wrote: Relatively new user with a question regarding abline. I want to draw a st. line fit to some data but I want the line to span the range of the x-data and NOT the plot limits. In short the line spans xmin to xmax(of plot axis) but I want it to span xmin to xmax (of x data). Can this but done with abline or do I have to use lines and construct the line from a+bx? A function with this capability was posted by Remko Duursma on 22/1/09. See: http://article.gmane.org/gmane.comp.lang.r.general/137344/match=ablinepiec e cheers, Rolf Turner P. S. Jim: Perhaps this function could/should be added to plotrix. If you are interested, I have written a help file for it. R. T. Hi Rolf and others, In fact Remko contributed that function to plotrix - ablineclip. Sorry. Wasn't aware of ablineclip(). Actually that function seems to use a quite different approach from that of ablinepiece(), and to be a substantial improvement. Thanks for pointing it out to us. cheers, Rolf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] abline; setting plot limits
On Mon, 16 Jun 2014 08:54:41 AM Rolf Turner wrote: > On 15/06/14 15:34, Paul Rydelek wrote: > > Relatively new user with a question regarding abline. > > > > I want to draw a st. line fit to some data but I want the line to span the > > range of the x-data and NOT the plot limits. > > In short the line spans xmin to xmax(of plot axis) but I want it to span > > xmin to xmax (of x data). > > Can this but done with abline or do I have to use lines and construct the > > line from a+bx? > > A function with this capability was posted by Remko Duursma on 22/1/09. See: > > http://article.gmane.org/gmane.comp.lang.r.general/137344/match=ablinepiec > > e > > cheers, > > Rolf Turner > > P. S. Jim: Perhaps this function could/should be added to plotrix. If > you are interested, I have written a help file for it. > > R. T. Hi Rolf and others, In fact Remko contributed that function to plotrix - ablineclip. 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] abline; setting plot limits
On 15/06/14 15:34, Paul Rydelek wrote: Relatively new user with a question regarding abline. I want to draw a st. line fit to some data but I want the line to span the range of the x-data and NOT the plot limits. In short the line spans xmin to xmax(of plot axis) but I want it to span xmin to xmax (of x data). Can this but done with abline or do I have to use lines and construct the line from a+bx? A function with this capability was posted by Remko Duursma on 22/1/09. See: http://article.gmane.org/gmane.comp.lang.r.general/137344/match=ablinepiece cheers, Rolf Turner P. S. Jim: Perhaps this function could/should be added to plotrix. If you are interested, I have written a help file for it. R. T. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading time series csv file with read.zoo issues, then align time stamps
index = 1:2 is missing. On Sun, Jun 15, 2014 at 2:39 PM, Henry wrote: > Goal: get time series data interpolated on to desired time stamps. > I have two or more data sets that have time stamps that vary from 5 mins to > 3-5 hours. > I want to get all the data put on common time stamps e.g. "00:05:00" > intervals. > > I asked Gabor and got some very good code ( zoo aggregate, na.spline, > na.approx) but I'm having trouble getting the csv file read in and converted > to a zoo object so I can try getting these functions going again. Here is > what Gabor sent last time. > > _start of what Gabor sent __ > If you are using zoo then the zoo FAQ discusses grids >http://cran.r-project.org/web/packages/zoo/index.html > and the other 4 vignettes (pdf documents) and reference manual on that > page discuss more. > > zoo does not supply its own time classes except where classes are > elsewhere missing. Its design is completely independent of the time > class and it works with any time class that supports certain methods > (and that includes all popular ones). See R News 4/1 for more on date > and time classes. > > Here is some code: > > Lines <- "10/11/2011 23:30:01 432.22 > 10/11/2011 23:31:17 432.32 > 10/11/2011 23:35:00 432.32 > 10/11/2011 23:36:18 432.22 > 10/11/2011 23:37:18 432.72 > 10/11/2011 23:39:19 432.23 > 10/11/2011 23:40:02 432.23 > 10/11/2011 23:45:00 432.23 > 10/11/2011 23:45:20 429.75 > 10/11/2011 23:46:20 429.65 > 10/11/2011 23:50:00 429.65 > 10/11/2011 23:51:22 429.75 > 10/11/2011 23:55:01 429.75 > 10/11/2011 23:56:23 429.55 > 10/12/2011 0:00:07 429.55 > 10/12/2011 0:01:24 429.95 > 10/12/2011 0:05:00 429.95 > 10/12/2011 0:06:25 429.85 > 10/12/2011 0:10:00 429.85 > 10/12/2011 0:11:26 428.85 > 10/12/2011 0:15:00 428.85 > 10/12/2011 0:20:03 428.85 > 10/12/2011 0:21:29 428.75 > 10/12/2011 0:25:01 428.75 > 10/12/2011 0:30:01 428.75 > 10/12/2011 0:31:31 428.75" > > library(zoo) > library(chron) > > fmt <- "%m/%d/%Y %H:%M:%S" > toChron <- function(d, t) as.chron(paste(d, t), format = fmt) > > z <- read.zoo(text = Lines, index = 1:2, FUN = toChron) > > # 5 minute aggregates > m5 <- times("00:05:00") > ag5 <- aggregate(z, trunc(time(z), m5), mean) > > # 5 minute spline fit > g <- seq(trunc(start(z), m5), end(z), by = m5) > na.spline(z, xout = g) > > # 5 minute linear approx > na.approx(z, xout = g) > end of what Gabor sent_ > > My csv data looks like this.when I look at the file with NotePad++ I see > the commas. > > > TimeStamp Sea_Temperature_F > 12/31/2011 13:24:00 52 > 12/31/2011 16:44:06 52 > 12/31/2011 20:44:06 53 > 01/01/2012 00:44:06 53 > 01/01/2012 04:44:06 53 > 01/01/2012 08:44:07 54 > 01/01/2012 12:26:00 54 > 01/01/2012 12:44:07 53 > 01/01/2012 16:44:07 53 > 01/01/2012 20:44:06 54 > 01/02/2012 00:44:09 54 > 01/02/2012 04:44:06 55 > 01/02/2012 08:44:07 55 > 01/02/2012 12:44:06 56 > 01/02/2012 13:04:00 56 > 01/02/2012 16:44:07 57 > 01/02/2012 20:44:07 58 > 01/03/2012 00:44:07 58 > 01/03/2012 04:44:06 59 > 01/03/2012 08:44:06 59 > 01/03/2012 10:48:00 59 > 01/03/2012 12:44:06 58 > 01/03/2012 16:44:06 58 > 01/03/2012 20:44:07 59 > 01/04/2012 00:44:06 59 > 01/04/2012 04:44:07 58 > 01/04/2012 08:44:07 58 > 01/04/2012 12:44:07 57 > 01/04/2012 15:30:00 57 > 01/04/2012 16:44:07 57 > 01/04/2012 20:44:06 57 > 01/05/2012 00:44:06 57 > > > The R code I'm trying to get working is as follows: (I'm trying to follow > code provided by Gabor) but I'm too embarrassed to ask him directly again. > > fmt <- "%M/%D/%Y %H:%M:%S" > toChron <- function(d, t) as.chron(paste(d, t), format = fmt) > seatemp <- read.zoo ("SampleSeaTempData-2.csv", sep=",", header=TRUE, > FUN=toChron) > > I get errors: > >> fmt <- "%M/%D/%Y %H:%M:%S" >> toChron <- function(d, t) as.chron(paste(d, t), format = fmt) >> seatemp <- read.zoo ("SampleSeaTempData-2.csv", sep=",", header=TRUE, >> FUN=toChron) > Error in paste(d, t) : argument "t" is missing, with no default >> > > If I take the "FUN=toChron" out I get this error. There are 542 rows of > data. > >> seatemp <- read.zoo ("SampleSeaTempData-2.csv", sep=",", header=TRUE) > Error in read.zoo("SampleSeaTempData-2.csv", sep = ",", header = TRUE) : > index has 542 bad entries at data rows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 > 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 > 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 > 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 > 90 91 92 93 94 95 96 97 98 99 100 ... >> > > I guess there is too much going on that I don't understand: > - what does the toChron line do? how are "d" and "t" defined? > - why does the Gabor read.zoo line have "index=1:2
[R] reading time series csv file with read.zoo issues, then align time stamps
Goal: get time series data interpolated on to desired time stamps. I have two or more data sets that have time stamps that vary from 5 mins to 3-5 hours. I want to get all the data put on common time stamps e.g. "00:05:00" intervals. I asked Gabor and got some very good code ( zoo aggregate, na.spline, na.approx) but I'm having trouble getting the csv file read in and converted to a zoo object so I can try getting these functions going again. Here is what Gabor sent last time. _start of what Gabor sent __ If you are using zoo then the zoo FAQ discusses grids http://cran.r-project.org/web/packages/zoo/index.html and the other 4 vignettes (pdf documents) and reference manual on that page discuss more. zoo does not supply its own time classes except where classes are elsewhere missing. Its design is completely independent of the time class and it works with any time class that supports certain methods (and that includes all popular ones). See R News 4/1 for more on date and time classes. Here is some code: Lines <- "10/11/2011 23:30:01 432.22 10/11/2011 23:31:17 432.32 10/11/2011 23:35:00 432.32 10/11/2011 23:36:18 432.22 10/11/2011 23:37:18 432.72 10/11/2011 23:39:19 432.23 10/11/2011 23:40:02 432.23 10/11/2011 23:45:00 432.23 10/11/2011 23:45:20 429.75 10/11/2011 23:46:20 429.65 10/11/2011 23:50:00 429.65 10/11/2011 23:51:22 429.75 10/11/2011 23:55:01 429.75 10/11/2011 23:56:23 429.55 10/12/2011 0:00:07 429.55 10/12/2011 0:01:24 429.95 10/12/2011 0:05:00 429.95 10/12/2011 0:06:25 429.85 10/12/2011 0:10:00 429.85 10/12/2011 0:11:26 428.85 10/12/2011 0:15:00 428.85 10/12/2011 0:20:03 428.85 10/12/2011 0:21:29 428.75 10/12/2011 0:25:01 428.75 10/12/2011 0:30:01 428.75 10/12/2011 0:31:31 428.75" library(zoo) library(chron) fmt <- "%m/%d/%Y %H:%M:%S" toChron <- function(d, t) as.chron(paste(d, t), format = fmt) z <- read.zoo(text = Lines, index = 1:2, FUN = toChron) # 5 minute aggregates m5 <- times("00:05:00") ag5 <- aggregate(z, trunc(time(z), m5), mean) # 5 minute spline fit g <- seq(trunc(start(z), m5), end(z), by = m5) na.spline(z, xout = g) # 5 minute linear approx na.approx(z, xout = g) end of what Gabor sent_ My csv data looks like this.when I look at the file with NotePad++ I see the commas. TimeStamp Sea_Temperature_F 12/31/2011 13:24:00 52 12/31/2011 16:44:06 52 12/31/2011 20:44:06 53 01/01/2012 00:44:06 53 01/01/2012 04:44:06 53 01/01/2012 08:44:07 54 01/01/2012 12:26:00 54 01/01/2012 12:44:07 53 01/01/2012 16:44:07 53 01/01/2012 20:44:06 54 01/02/2012 00:44:09 54 01/02/2012 04:44:06 55 01/02/2012 08:44:07 55 01/02/2012 12:44:06 56 01/02/2012 13:04:00 56 01/02/2012 16:44:07 57 01/02/2012 20:44:07 58 01/03/2012 00:44:07 58 01/03/2012 04:44:06 59 01/03/2012 08:44:06 59 01/03/2012 10:48:00 59 01/03/2012 12:44:06 58 01/03/2012 16:44:06 58 01/03/2012 20:44:07 59 01/04/2012 00:44:06 59 01/04/2012 04:44:07 58 01/04/2012 08:44:07 58 01/04/2012 12:44:07 57 01/04/2012 15:30:00 57 01/04/2012 16:44:07 57 01/04/2012 20:44:06 57 01/05/2012 00:44:06 57 The R code I'm trying to get working is as follows: (I'm trying to follow code provided by Gabor) but I'm too embarrassed to ask him directly again. fmt <- "%M/%D/%Y %H:%M:%S" toChron <- function(d, t) as.chron(paste(d, t), format = fmt) seatemp <- read.zoo ("SampleSeaTempData-2.csv", sep=",", header=TRUE, FUN=toChron) I get errors: > fmt <- "%M/%D/%Y %H:%M:%S" > toChron <- function(d, t) as.chron(paste(d, t), format = fmt) > seatemp <- read.zoo ("SampleSeaTempData-2.csv", sep=",", header=TRUE, > FUN=toChron) Error in paste(d, t) : argument "t" is missing, with no default > If I take the "FUN=toChron" out I get this error. There are 542 rows of data. > seatemp <- read.zoo ("SampleSeaTempData-2.csv", sep=",", header=TRUE) Error in read.zoo("SampleSeaTempData-2.csv", sep = ",", header = TRUE) : index has 542 bad entries at data rows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ... > I guess there is too much going on that I don't understand: - what does the toChron line do? how are "d" and "t" defined? - why does the Gabor read.zoo line have "index=1:2" ? - why does the Gabor code have " FUN=toChron" ? The idea is to get two or more data streams "converted" to exact timestamp csv files with interpolated values and then I guess cbind the data into one data frame so I can plot together. I've read re. zoo csv file read issues/posts - e.g. getting the seconds (":00") to a
Re: [R] abline; setting plot limits
You can also use clip() before abline(): > x <- rnorm(25) > y <- rnorm(25) > plot(y~x) > clip(min(x), max(x), min(y), max(y)) > abline(lm(y~x)) But the clipping region will affect anything else you add to the plot after the clip command. In package plotrix, ablineclip() sets and resets the clipping region. David Carlson -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch Sent: Sunday, June 15, 2014 10:55 AM To: Paul Rydelek; r-help@r-project.org Subject: Re: [R] abline; setting plot limits On 14/06/2014, 11:34 PM, Paul Rydelek wrote: > Relatively new user with a question regarding abline. > > I want to draw a st. line fit to some data but I want the line to span > the range of the x-data and NOT the plot limits. > In short the line spans xmin to xmax(of plot axis) but I want it to > span xmin to xmax (of x data). > Can this but done with abline or do I have to use lines and construct > the line from a+bx? You can use lines() or segments(), you can't use abline(). Duncan Murdoch > > > Paul Rydelek, Ph.D. > 5232 Dorset Dr. > Memphis, TN 38117 > > > > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sort() depends on locale (and platform and build)
Hi, ... so something like this? [in foo.R] old.coll <- Sys.getlocale("LC_COLLATE") Sys.setlocale("LC_COLLATE", locale="C") Sys.setlocale("LC_COLLATE", locale=old.coll) Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sort() depends on locale (and platform and build)
On 15/06/2014 17:34, Marius Hofert wrote: Hi, Thanks for you help. I use R-devel under Ubuntu 14.04, here is the output of sessionInfo(): sessionInfo() R Under development (unstable) (2014-06-02 r65832) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.2.0 tools_3.2.0 I assume ICU was not found/installed when R was installed as executing the first couple of lines of the examples section of ?icuSetCollate leads to: Warning message: In icuSetCollate(case_first = "upper") : ICU is not supported on this build [1] "aarhus" "Aarhus" "safe" "test" "Zoo" Since only the (default) locale "C" gives the order I expected, I consider changing my ~/.Rprofile. But it certainly had a reason why I changed it to "en_US.UTF-8" at some point... hope that does not break anything else. Is there any "recommendation" what to use in ~/.Rprofile (the default?)? And is the 'recommended approach' to have ICU installed and change the sorting order via icuSetCollate if necessary? Yes. (You can use the locale category LC_COLLATE or icuSetCollate, but the recommended way to do the first is via the environment variables, not in .Rprofile.) I would have not expected any influence of the locale on the sorting order, that's quite good to know. In fact, the example came up after I tried to sort students' grades in a class with several students having the same last name (which I made unique by adding the first names with a '.' separator)... quite a 'delicate' issue... Cheers, Marius -- 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.
Re: [R] sort() depends on locale (and platform and build)
Hi, Thanks for you help. I use R-devel under Ubuntu 14.04, here is the output of sessionInfo(): > sessionInfo() R Under development (unstable) (2014-06-02 r65832) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.2.0 tools_3.2.0 I assume ICU was not found/installed when R was installed as executing the first couple of lines of the examples section of ?icuSetCollate leads to: Warning message: In icuSetCollate(case_first = "upper") : ICU is not supported on this build [1] "aarhus" "Aarhus" "safe" "test" "Zoo" Since only the (default) locale "C" gives the order I expected, I consider changing my ~/.Rprofile. But it certainly had a reason why I changed it to "en_US.UTF-8" at some point... hope that does not break anything else. Is there any "recommendation" what to use in ~/.Rprofile (the default?)? And is the 'recommended approach' to have ICU installed and change the sorting order via icuSetCollate if necessary? I would have not expected any influence of the locale on the sorting order, that's quite good to know. In fact, the example came up after I tried to sort students' grades in a class with several students having the same last name (which I made unique by adding the first names with a '.' separator)... quite a 'delicate' issue... Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] abline; setting plot limits
On 14/06/2014, 11:34 PM, Paul Rydelek wrote: > Relatively new user with a question regarding abline. > > I want to draw a st. line fit to some data but I want the line to span the > range of the x-data and NOT the plot limits. > In short the line spans xmin to xmax(of plot axis) but I want it to span > xmin to xmax (of x data). > Can this but done with abline or do I have to use lines and construct the > line from a+bx? You can use lines() or segments(), you can't use abline(). Duncan Murdoch > > > Paul Rydelek, Ph.D. > 5232 Dorset Dr. > Memphis, TN 38117 > > > > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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 converting a list of grids to a list of polygons
Hi. For a spatial analysis (its visualization) I need to produce a map of conditions and traits. When I used SpatialPixelsDataFrame (sp package) my grid cells were regular and between each row was a small gap, which is not only messy but incorrect. So I generated the coords of each grid from the centroids in order to elongate the cells manually (or does anybody know another way to solve this?). But I got stuck when I tried to convert the XMIN, XMAX, YMIN, YMAX - corner points to a list of polygons (and keeping at least the ID as individuell reference). I really don’t get it, how can I read data of this format as a list of polygons? „head"(ID, XMIN, XMAX, YMIN, YMAX, lat, lng, altc_mean) polys <- Polygons(list(Polygon(assemblage[,c("XMIN", "XMAX", "YMIN", "YMAX“)])), ID=assemblage$ID) SP <- SpatialPolygons(polys) SPDF <- SpatialPolygonsDataFrame(SP, data=data.frame(x= assemblage$lng, y= assemblage$lat, row.names=row.names(SP))) Already thanks for your help, Stefan -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-converting-a-list-of-grids-to-a-list-of-polygons-tp4692142.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] imlib2, pixmap?
hi. i'm doing some statistical analysis on image files. the pixmap package is great, but has the limitation that it is only able to read (and write) data in PNM format. there's a nice unix/linux/... library known as imlib2 that is able to read and write image data in many different formats. i'm wondering if anyone has written (in C, presumably) code to allow creating a pixmap from any image format known to imlib2? (i know about ImageMagick's convert program, and have been doing things this way, but it is somewhat inefficient, and aesthetically not as pleasing). if no one has done this, i'll probably do it (at least for my own use, never having produced a "public" package). cheers, Greg Minshall __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 draw Bubble chart with mini pie charts as bubbles in R
Hi Jim, Very great help. Bunch of thanks. Yours, Amir On Sun, 6/15/14, Jim Lemon wrote: Subject: Re: [R] How to draw Bubble chart with mini pie charts as bubbles in R To: r-help@r-project.org Date: Sunday, June 15, 2014, 5:10 AM On Sat, 14 Jun 2014 01:03:21 PM Agony wrote: > Dear all, > Good day! > > Could anybody help me how to draw a bubble chart with mini pie charts as > bubbles in R ? Introducing any experiences, books, booklet or source code > will appreciated. > Hi Amir, The floating.pie function (plotrix) might do what you want. For example: # first create a simple function to do the chart pie_bubbles<-function(xpos,ypos,radii,sectors, sector_col=NULL,main="",xlab="",ylab="") { xlim<-c(min(xpos-radii),max(xpos+radii)) ylim<-c(min(ypos-radii),max(ypos+radii)) nbubbles<-length(xpos) if(is.null(sector_col)) { sector_col<-list() for(scol in 1:nbubbles) sector_col[[scol]]<-rainbow(length(sectors[[scol]])) } plot(0,xlim=xlim,ylim=ylim,type="n", main=main,xlab=xlab,ylab=ylab) for(bubble in 1:nbubbles) floating.pie(xpos=xpos[bubble],ypos=ypos[bubble], x=sectors[[bubble]],radius=radii[bubble], col=sector_col[[bubble]]) } # set the x positions xpos<-c(2,4,6,8,10) # and the y positions ypos<-c(4,8,6,10,2) # the radii are the "bubble" radii radii<-c(1,0.5,1.2,0.7,1.3) # these are the sector extents of the pies sectors<-list(1:4,c(5,3,8,6,2),c(3,2,1),c(3,7,5,8),c(2.5,3.7)) # get the plotrix package library(plotrix) pie_bubbles(xpos,ypos,radii,sectors,main="Pie bubbles") The above is pretty basic, but it should get you started. 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.
[R] abline; setting plot limits
Relatively new user with a question regarding abline. I want to draw a st. line fit to some data but I want the line to span the range of the x-data and NOT the plot limits. In short the line spans xmin to xmax(of plot axis) but I want it to span xmin to xmax (of x data). Can this but done with abline or do I have to use lines and construct the line from a+bx? Paul Rydelek, Ph.D. 5232 Dorset Dr. Memphis, TN 38117 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Output for Boot function in Car package
Dear David and Dan, Yes, the column labelled "bootMed" is the median of the bootstrapped values. As it turns out, this isn't documented in the help for the car package, nor in the on-line appendix on bootstrapping from the CAR book. It's easy, however, to print car:::summary.boot to see the straight-forward things that it does. I hope this helps, John John Fox, Professor McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Sat, 14 Jun 2014 15:08:21 -0700 David Winsemius wrote: > > On Jun 14, 2014, at 1:15 AM, Dan Hughes wrote: > > > Dear users, > > > > Can anyone help with a rather simplistic question about the interpretation > > of output using the Boot ( ) function in the Car package? > > > > I am trying to bootstrap a simple univariate linear regression in order to > > look at the bootstrap regression coefficients e.g. > > > > mod1 <- lm (y~x) > > mod1.b <- Boot(mod1, R=999) > > summary (mod1.b) > > > > This returns output like this: > > > > R original bootBias bootSE bootMed > > (Intercept) 999 5.365528 -8.0960e-05 0.0501306 5.365241 > > x 999 0.0322117.3683e-05 0.0029743 0.032158 > > > > I'm having trouble finding out what "bootMed" means. If 'original' is the > > non-bootstrapped regression coefficient, is bootMed the bootstrapped > > regression coefficient? > > > > I presume this is a frighteningly simple question for regular car package > > users, but I can't seem to find an explanation what this means. > > I'm not a regular or even an intermittent user of `car` but offhand I would > suspect it is the median. > > Do read the Posting Guide, > and the help page for Boot and the tutorial that is linked from that help > page, > and please learn to post in plain text. > > > > > Best wishes > > > > Dan Hughes > > > > [[alternative HTML version deleted]] > > -- > > David Winsemius > Alameda, CA, USA > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] sort() depends on locale
On 15/06/2014 12:16, Duncan Murdoch wrote: On 15/06/2014, 1:15 AM, Marius Hofert wrote: Hi, If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "L.Y" "Lu" whereas using invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8")) results in sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "Lu" "L.Y" I know this issue has appeared already (https://stat.ethz.ch/pipermail/r-help//2012-February/304089.html), I just don't see a reason for the second output: either '.' comes before letters, then the result should be "L.Q" "L.Y" "Lu" or it comes afterwards, then it should be "Lu" "L.Q" "L.Y" -- the above result thus seems inconsistent to any useful notion of 'sort' (?) I don't see this either, but it appears that on your platform the "." is simply being ignored, which might be a useful kind of sorting in some contexts. ICU implements that: icuSetCollate(locale="en_US", alternate_handling="shifted") sort(c("L.Y", "Lu", "L.Q")) See ?icuSetCollate and the references there and in ?Comparison. -- 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.
Re: [R] sort() depends on locale
On 15/06/2014, 1:15 AM, Marius Hofert wrote: > Hi, > > If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then > >> sort(c("L.Y", "Lu", "L.Q")) > [1] "L.Q" "L.Y" "Lu" > > whereas using invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8")) results in > >> sort(c("L.Y", "Lu", "L.Q")) > [1] "L.Q" "Lu" "L.Y" > > I know this issue has appeared already > (https://stat.ethz.ch/pipermail/r-help//2012-February/304089.html), I > just don't see a reason for the second output: either '.' comes before > letters, then the result should be > "L.Q" "L.Y" "Lu" or it comes afterwards, then it should be "Lu" "L.Q" > "L.Y" -- the above result thus seems inconsistent to any useful notion > of 'sort' (?) I don't see this either, but it appears that on your platform the "." is simply being ignored, which might be a useful kind of sorting in some contexts. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to draw Bubble chart with mini pie charts as bubbles
Dear Amir, There are a couple of panel functions in loa, a package of lattice add-ins, that might be of help: require(loa) # Use a subsample of lat.lon.meuse dataset in loa temp <- lat.lon.meuse[sample(1:155, 15),] # plot Cu/Pb/Zn pie plots at sampling locations loaPlot(copper+lead+zinc~longitude*latitude, panel=panel.zcasePiePlot, data=temp) # then rescale smaller pie segments on the fly loaPlot(copper*10+lead*4+zinc~longitude*latitude, panel=panel.zcasePiePlot, data=temp) Best Wishes, Karl -- Message: 5 Date: Sat, 14 Jun 2014 13:03:21 -0700 (PDT) From: Agony To: r-help@r-project.org Subject: [R] How to draw Bubble chart with mini pie charts as bubbles in R Message-ID: <1402776201.7516.yahoomailba...@web120401.mail.ne1.yahoo.com> Content-Type: text/plain; charset=us-ascii Dear all, Good day! Could anybody help me how to draw a bubble chart with mini pie charts as bubbles in R ? Introducing any experiences, books, booklet or source code will appreciated. Bunch of thanks. Best, Amir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.