Re: [R] Lattice: How to color the data points in splom() according to the panel they are plotted?

2010-01-16 Thread Peter Ehlers
Marius Hofert wrote: Dear ExpeRts, I have the scatter plot matrix as given below. I would like the different "sub-plots" in the scatter plot matrix to be colored differently. How do I get all points shown in the upper-left plot (on position (1,1) in the scatter plot matrix) to be plotted in b

[R] Loess and predict

2010-01-16 Thread lol zino
Alright, I apologize for this basic question - I am both an R and loess noob. I am trying to predict the values of column Y in data1 (10x18 entries) using a loess fit on training (500x18 entries) and columns A B and C. (training are not members of data1) fit <- loess(Y ~ A + B + C, training)

Re: [R] how to manipulate this data? Thank you very much!

2010-01-16 Thread jim holtman
try this: > x <- read.table(textConnection("group student rating + A 1 3 + A 2 2 + A 3 2 + A 4 3 + A 5 1 + A 6 2 + A 7 3 + B 1

Re: [R] Confusion in 'quantile' and getting rolling estimation of sample quantiles

2010-01-16 Thread Gabor Grothendieck
There is no quantile method defined for zoo objects so it falls through to the default method but that method does not work for zoo objects. Try this: set.seed(123) rn <- rnorm(500) quantile(rn, 0.8) quantile(coredata(zoo(rn)), 0.8) In the second question the error message tells you what the pro

Re: [R] Hierarchical Linear Model using lme4's lmer

2010-01-16 Thread Doug Adams
Hehe (about the kitchen sink) Thanks very much to all three of you. Douglas Bates-2 wrote: > > On Sat, Jan 16, 2010 at 8:20 AM, Walmes Zeviani > wrote: >> >> Doug, >> >> It appears you are mixing nlme and lme4 formulation type. >> On nlme library you type >> >> lme(y~x, random=~1|subjetc) >>

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
Interesting! Now, if I change the "cost matrix", D, in the LSAP formulation slightly such that it is quadratic, it finds the best solution to your example: pMatrix.min <- function(A, B) { # finds the permutation P of A such that ||PA - B|| is minimum # in Frobenius norm # Uses the linear-sum

[R] how to manipulate this data? Thank you very much!

2010-01-16 Thread jie feng
Hi, R experts: I am asking for helps with manipulating this data: we have different groups: A,B, C, and so on. In each group, we have different students, for example, we have 6 students in A and 5 students in B. Each student gives a rating, which ranges from 1 to 3. We want to manipulate this dat

Re: [R] Drought severity index: Excel to R

2010-01-16 Thread jim holtman
Try this: DS <- structure(list(anomaly = c(-27.3, 14.4, 29, -38.1, -3.4, 55.1, -1, 21.9, -10.9, -7.8, -48.2, -44.9, -43.8, -10.3, 44.2, -0.5, 96.7, -32, -0.2, -38.6, 73.6, -17.5, -57.8, 10.7, -33.4, 46.1, 26.7, -37.3, 1.2, 36.3, 39.6, 31), prev6mon = c(NA, NA, NA, NA, NA, 29.7, 56, 63.5, 23.6, 53.

Re: [R] More than on loop??

2010-01-16 Thread jim holtman
I found the data you sent with the help of David Winsemius. Are you just trying to count the number of amino acids in each of the groups? Is it something like this: > # split by the Label > x <- split(amino, amino$Label) > # now count the number of aminos in each group > lapply(x, function(.lab)

[R] Confusion in 'quantile' and getting rolling estimation of sample quantiles

2010-01-16 Thread Saji Ren
Guys: 1).When I using the 'quantile' function, I get really confused. Here is what I met: > x<-zoo(rnorm(500,0,1)) > quantile(x,0.8) 400 1.060258 > c=rnorm(500,0,1) > quantile(c,0.8) 80% 0.9986075 why do the results display different? Is that because of the different type of the

Re: [R] More than on loop??

2010-01-16 Thread jim holtman
Since there was no data, it is hard to propose a solution. I would estimate that 'loops' are not required; the use of 'table' or one of the 'apply' functions will probably provide the answer. On Sat, Jan 16, 2010 at 8:04 PM, che wrote: > > Thank you very much for your help, > > you have been ex

Re: [R] More than on loop??

2010-01-16 Thread che
Thank you very much for your help, you have been excused to have a suspicion, but dont worry i am not cheating, it is not a home work, rather it is a pre-project task that i have to deal with in order to prepare to my project, and i cant understand this programming things alone, i tried my best

Re: [R] More than on loop??

2010-01-16 Thread David Winsemius
On Jan 16, 2010, at 7:09 PM, che wrote: hello every one, How to function more than one loop in R? for (i in 1:3) { for (j in 1:2) { for (k in letters[1:4]) { print(paste(i , j, k) ) } } } I'm afraid I develop a strong suspicion that a problem is homewor

[R] More than on loop??

2010-01-16 Thread che
hello every one, How to function more than one loop in R? I have the following problem to be solved with the a method of three loops, can you help me please? The data is attached with this message. The data is composed of two parts, cleaved (denoted by “cleaved”) and non cleaved (denoted by “no

[R] Quasi-Poisson regression - using parameter estimates for QAICc

2010-01-16 Thread dm
Quasi-Poisson regression - using parameter estimates for QAICc Hello, I am using lmer (package lme4), for a GLMM, where I am modeling overdispered data with 1 random effect and several fixed effects. I want to use QAICc for my model selection, however I have 2 concerns 1) I don't know how to pr

Re: [R] Comparing dates in dataframes

2010-01-16 Thread jim holtman
If you have a vector of the quarter hours of good weather (gw), then to create the column in the arr dataframe you would do arr$GoodWeather <- arr$quarter %in% gw This says that if the quarter hour of the arrival is in the 'gw' vector, set the value TRUE; otherwise FALSE. On Sat, Jan 16, 2010 at

Re: [R] Sweave - How to use local objects in code chunks

2010-01-16 Thread Charles C. Berry
On Sat, 16 Jan 2010, Ista Zahn wrote: I don't think it works that way. The .Rnw file should be self-contained. Put all the R code in the .Rnw file (or keep it in a separate file and source() it into the .Rnw file). Right. So the issue is to figure out how to do this in a way that allows Jan-H

Re: [R] Extracing only Unique Rows based on only 1 Column

2010-01-16 Thread Gabor Grothendieck
Try this where DF is your data frame: subset(DF, !duplicated(ID)) or equivalently: DF[!duplicated(DF$ID), ] On Sat, Jan 16, 2010 at 5:04 PM, Bryan M Hangartner wrote: > To Whomever is Interested, > > I have spent several days searching the web, help files, the R wiki and the > archives of thi

Re: [R] Sweave - How to use local objects in code chunks

2010-01-16 Thread Ista Zahn
I don't think it works that way. The .Rnw file should be self-contained. Put all the R code in the .Rnw file (or keep it in a separate file and source() it into the .Rnw file). -Ista On Sat, Jan 16, 2010 at 3:35 PM, Jan-Henrik Pötter wrote: > Hello, > > I wrote a function create_report that ca

Re: [R] optimization problem

2010-01-16 Thread Erwin Kalvelagen
I believe this is a very good approximation but not a 100% correct formulation of the original problem. E.g. for A <- matrix(c( -0.62668585718,-0.78785288063,-1.32462887089, 0.63935994044, -1.99878497801, 4.42667400292, 0.65534961645, 1.86914537669, -0.97229929674, 2.37404268115, 0.0122

Re: [R] Comparing dates in dataframes

2010-01-16 Thread James Rome
I don't want to merge the data frames because there are many entries in the arrival frame for each one in the weather frame. And it is the missing dates and quarters in the weather frame that constitute the date I want, namely those arrivals that occurred in bad (or good) weather. But I will

Re: [R] Extracing only Unique Rows based on only 1 Column

2010-01-16 Thread Dennis Murphy
Hi: This question arose a few days ago. There are two simple ways to do this: (i) using ddply in the plyr package and (ii) using the firstobs() function in the doBy package. (i) library(plyr) > ddply(x, .(ID), head, n = 1) ID Time1 Time2 1 1 3 4 2 2 3 5 3 3 4 5 (ii

[R] Extracing only Unique Rows based on only 1 Column

2010-01-16 Thread Bryan M Hangartner
To Whomever is Interested, I have spent several days searching the web, help files, the R wiki and the archives of this mailing list for a solution to this problem, but nonetheless I apologize in advance if I have missed something obvious. The problem is this; I have a 5-column data frame

Re: [R] Comparing dates in dataframes

2010-01-16 Thread Stephan Kolassa
Hi, it looks like when you read in your data.frames, you didn't tell R to expect dates, so it treats the Date columns as factors. Judicious use of something along these lines before doing your comparisons may help: arr$Date <- as.Date(as.character(arr$Date),format=something) Then again, it

[R] Comparing dates in dataframes

2010-01-16 Thread James Rome
I have two data frames. One (arr) has all arrivals to an airport for a year, and the other (gw) has the dates and quarter hour of the day when the weather is good. arr has a Date and quarter hour column. >names(arr) [1] "Date" "weekday" "hour" "month""minute" [6] "q

Re: [R] Drought severity index: Excel to R

2010-01-16 Thread David Winsemius
On Jan 16, 2010, at 2:57 PM, Muhammad Rahiz wrote: Dear all, I'm trying to make an R code for the drought severity index (DSI) developed by Philips and McGregor (1998). You can refer to the description of the algorithm on page 19 from http://dissertations.port.ac.uk/229/01/MaloneS.pdf Th

[R] Sweave - How to use local objects in code chunks

2010-01-16 Thread Jan-Henrik Pötter
Hello, I wrote a function create_report that calls the function Sweave. create_report shall be used to create a pdf-report about an lm-Object which is passed as an argument to create_report. I try to use an object sel_model, that is created within the function environment of create_report and lat

Re: [R] predict.glm

2010-01-16 Thread David Winsemius
On Jan 16, 2010, at 1:34 PM, Maurice Charbit wrote: Hi, See below I reply your message for [R] predict.glm & newdata posted on Fri Apr 4 21:02:24 CEST 2008 You say it ##works fine but it does not: if you look at the length o

Re: [R] predict.glm

2010-01-16 Thread Peter Ehlers
Maurice, The 'newdata' argument should be a data.frame with the same names as used for your predictors in the glm formula. For the data you quote below (after fixing the missing y1), try: yhat <- predict(reg1, newdata = data.frame(x1 = x2)) length(yhat) [1] 200 A careful reading of ?predict wo

Re: [R] plotting moving range control chart

2010-01-16 Thread Filthy McNasty
Tom Hopper wrote: >The problem is the (apparent?) inability to produce moving range process >behavior (a.k.a. "control") charts with individuals data in the package >"qcc" (v. 2.0). I have also struggled with the same limitation in package >"IQCC" (v. 1.0). The moving range chart has the same

[R] gWidgets: plotting problem

2010-01-16 Thread Walther, Alexander
Dear list, i incorporated ggraphics into a loop that subsequently runs over a range of values. code looks as follows: multi = function(...){ for (i in 1:length(Lower)) # { ggraphics(cont=nb) par(mar=c(0,0,0,0)) plot(x,y,ylim=c(-2,2),xlim=c(Lower[i],Upper[i]),axes =TRUE, frame.plot = FALSE) }

[R] Drought severity index: Excel to R

2010-01-16 Thread Muhammad Rahiz
Dear all, I'm trying to make an R code for the drought severity index (DSI) developed by Philips and McGregor (1998). You can refer to the description of the algorithm on page 19 from http://dissertations.port.ac.uk/229/01/MaloneS.pdf The code is given in Excel as the following and can be fo

Re: [R] predict.glm

2010-01-16 Thread Maurice Charbit
Hi, See below I reply your message for [R] predict.glm & newdata posted on Fri Apr 4 21:02:24 CEST 2008 You say it ##works fine but it does not: if you look at the length of yhat2, you will find 100 and not 200 as expected. In fa

Re: [R] 'nlme' library - lme function results

2010-01-16 Thread Dieter Menne
Peter Ehlers wrote: > > > .. or get both from VarCorr(model): > > VarCorr(fm2) > #Subject = pdLogChol(1) > #Variance StdDev > #(Intercept) 3.266784 1.807425 > #Residual2.049456 1.431592 > > Krr.. I knew I had some sort of blackout. Dieter -- View this message in context

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
Yes, it can be formulated as an LSAP. It works just fine. I have checked it with several 3 x 3 examples. Here is another convincing example: n <- 50 A <- matrix(rnorm(n*n), n, n) > # Find P such that ||PA - C|| is minimum vec <- sample(1:n, n, rep=FALSE) # a random permutation C <- A[v

Re: [R] optimization problem

2010-01-16 Thread Erwin Kalvelagen
I also have doubts this can be formulated correctly as a linear assignment problem. You may want to check the results with a small example. Erwin Erwin Kalvelagen Amsterdam Optimization Modeling Group er...@amsterdamoptimization.com

[R] Testing Equality of Covariance Matrices??

2010-01-16 Thread Robert Lonsinger
Dear Users, I am conducting a function analysis with 6 groupings and 11 predicter variables. fit<-lda(Groups~ x1 + x2+ + x11, data=my.data, na.action="na.omit") My resulting misclassification rates are low, and although this is one of the goals, I would like to test assumption of equality am

Re: [R] turning an element of list into a vector

2010-01-16 Thread David Winsemius
On Jan 16, 2010, at 12:05 PM, alessia matano wrote: Dear all, I am trying to apply the sapply function on a list, which comes out from a matrix of 25 rows and two columns, so that each element of the list, is a two column element. In my function within sapply, say f, I would like each element

[R] turning an element of list into a vector

2010-01-16 Thread alessia matano
Dear all, I am trying to apply the sapply function on a list, which comes out from a matrix of 25 rows and two columns, so that each element of the list, is a two column element. In my function within sapply, say f, I would like each element of the list to become a vector so that I can transpose

Re: [R] La.svd of a symmetric matrix

2010-01-16 Thread David Winsemius
On Jan 16, 2010, at 8:10 AM, Stefano Sofia wrote: Dear R list users, the singluar value decomposition of a symmetric matrix M is UDV^(T), where U = V. La.svd(M) gives as output three elements: the diagonal of D and the two orthogonal matrices u and vt (which is already the transpose of v)

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
Klaus, You also need to make a change in the main function, as shown below. pMatrix.min <- function(A, B) { # finds the permutation P of A such that ||PA - B|| is minimum # in Frobenius norm # Uses the linear-sum assignment problem (LSAP) solver # in the "clue" package # Returns P%*%A and the pe

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
Thanks, Erwin, for pointing out this mistake. Here is the correct function for Frobenius norm. Klaus - Just replace the old `dist' with the following one. dist <- function(A, B) { # Frobenius norm of A - B n <- nrow(A) sqrt(sum((B - A)^2)) } Ravi.

Re: [R] Hierarchical Linear Model using lme4's lmer

2010-01-16 Thread Douglas Bates
On Sat, Jan 16, 2010 at 8:20 AM, Walmes Zeviani wrote: > > Doug, > > It appears you are mixing nlme and lme4 formulation type. > On nlme library you type > > lme(y~x, random=~1|subjetc) > > On lme4 library you type > > lmer(y~x+(1|subject)) > > You mixed them. > > At your disposal. Which is what

Re: [R] Hierarchical Linear Model using lme4's lmer

2010-01-16 Thread Walmes Zeviani
Doug, It appears you are mixing nlme and lme4 formulation type. On nlme library you type lme(y~x, random=~1|subjetc) On lme4 library you type lmer(y~x+(1|subject)) You mixed them. At your disposal. Walmes. Doug Adams wrote: > > Hi, > > I was wondering: I've got a dataset where I've got

[R] La.svd of a symmetric matrix

2010-01-16 Thread Stefano Sofia
Dear R list users, the singluar value decomposition of a symmetric matrix M is UDV^(T), where U = V. La.svd(M) gives as output three elements: the diagonal of D and the two orthogonal matrices u and vt (which is already the transpose of v). I noticed that the transpose of vt is not exactly u. Wh

Re: [R] 'nlme' library - lme function results

2010-01-16 Thread Peter Ehlers
Dieter Menne wrote: Michal Figurski wrote: I am running a simple mixed effects model using lme(). The call looks like this: fit <- lme(Analyte~Sample, data=Data, random=~1 | Run) I am particularly interested in the estimated random effects. When I print the 'fit' object, it looks somethin

Re: [R] What is the newline escape sequence when using the Hershey fontfamily?

2010-01-16 Thread Henrique Dallazuanna
You should try this: xx <- c(1:10) yy <- c(11:20) xyplot(yy~xx, main=list("This title should\nhave two lines" , fontfamily="HersheySymbols" ) ) On Fri, Jan 15, 2010 at 11:00 AM, Douglas Walcerz wrote: > Hello! > > The question is simple: What is the escape sequence for a new line when >

[R] [R-pkgs] doMPI 0.1-4

2010-01-16 Thread Stephen Weston
I'd like to announce the availability of version 0.1-4 of the "doMPI" package, a parallel backend for the "foreach" package, which acts as an adaptor to the "Rmpi" package. The package has been uploaded to CRAN and is now available under the GPL-2 license. In addition to fixing a few problems in

[R] [R-pkgs] itertools 0.1-1

2010-01-16 Thread Stephen Weston
I'd like to announce the availability of the new "itertools" package, which provides a variety of functions used to create iterators, as defined by REvolution Computing's "iterators" package. The package has been uploaded to CRAN and is now available under the GPL-2 license. The "itertools" packa

Re: [R] advice/opinion on "<-" vs "=" in teaching R

2010-01-16 Thread Jim Lemon
On 01/15/2010 10:08 PM, Peter Dalgaard wrote: Barry Rowlingson wrote: On Fri, Jan 15, 2010 at 3:45 AM, Erin Hodgesswrote: Hi R People: I'm teaching a statistical computing class using R starting next week (yay!) and I have an opinion type question, please. I'm old school and use "<-" in an a

Re: [R] 'nlme' library - lme function results

2010-01-16 Thread Dieter Menne
Michal Figurski wrote: > > I am running a simple mixed effects model using lme(). The call looks > like this: > fit <- lme(Analyte~Sample, data=Data, random=~1 | Run) > > I am particularly interested in the estimated random effects. When I > print the 'fit' object, it looks something like ex

[R] ess-roxy: Roxygen support for ESS

2010-01-16 Thread Peter Danenberg
We're pleased to announce that Henning Redestig finally implemented ESS support for Roxygen: http://www.metabolome.jp/download/ess-roxy/ess-roxy.el/view ess-roxy includes paragraph fill, hiding, template generation, etc. __ R-help@r-project.org maili