Re: [R] I bet apply has a solution

2012-02-06 Thread ilai
duplicated(Data..) On Mon, Feb 6, 2012 at 11:34 AM, LCOG1 wrote: > Hi all > For the data below, I would like to return a logical value indicating > differences in the data. > > #Create data > Data..<-data.frame(a=rep(1,10),b=c(rep(1,9),2),c=c(rep(1,8),2,2)) > >   a b c > 1  1 1 1 > 2  1 1 1 > 3  

Re: [R] binomial vs quasibinomial

2012-02-07 Thread ilai
Not really an R question, now is it ? more like pure stats. I'm guessing you didn't get an answer because this list can't tell you how to analyze your data (or in your case, approve an incorrect analysis). Regarding the part of your question that is R related, I think you may be confused on what t

Re: [R] Setting up infile for R CMD BATCH

2012-02-07 Thread ilai
You're not missing anything. In your output.Rout: the ">1" right after the source('test') is the "1" inputed from answers.R. the "[1] 1" is the result of test. Remove the second line from answers.R and see what happens (hint: script ends after the readline prompt). Just out of curiosity, why will y

Re: [R] Setting up infile for R CMD BATCH

2012-02-07 Thread ilai
On Tue, Feb 7, 2012 at 10:50 PM, ilai wrote: > Ahh, > I think I'm getting it now. Well, readlines() is not going to work for > you. The help file ?readline clearly states "In non-interactive use > the result is as if the response was RETURN and the value is ‘""’.&

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread ilai
gram work in both interactive and batch mode. > > Thanks again, > Gang > > > On Wed, Feb 8, 2012 at 12:50 AM, ilai wrote: >> Ahh, >> I think I'm getting it now. Well, readlines() is not going to work for >> you. The help file ?readline clearly states "

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread ilai
s you suggested previously with eval(), for example. However, is > there an approach to keeping the original program so that the user > could run both interactive and batch mode? That probably requires > modifying the readline() part, but how? > > Thanks, > Gang > > >

Re: [R] basic debugging

2012-02-08 Thread ilai
?debug will satisfy your curiosity regarding "debug mode" - strictly speaking it is not a "mode", just another function. On Wed, Feb 8, 2012 at 7:30 PM, R. Michael Weylandt wrote: > What is your question? More interestingly, what is "debug mode" in R? > > I'd suggest you look at traceback() --

Re: [R] Row-wise kronecker product with Matrix package

2012-02-09 Thread ilai
Maybe one of these will improve: >help.search('kronecker') ... spam::kronecker Kronecker Products on Sparse Matrices spam::spam.classClass "spam" base::kronecker Kronecker Products on Arrays Matrix::kronecker-methods Methods for Function 'kronecker()'

[R] Lattice 3d coordinate transformation

2012-02-09 Thread ilai
Hello List! I asked this before (with no solution), but maybe this time... I'm trying to project a surface to the XY under a 3d cloud using lattice. I can project contour lines following the code for fig 13.7 in Deepayan Sarkar's "Lattice, Multivariate Data Visualization with R", but it fails when

Re: [R] Lattice 3d coordinate transformation

2012-02-09 Thread ilai
Oops. Obviously I mean "> A working example: > require(lattice) > ..." On Thu, Feb 9, 2012 at 12:13 PM, ilai wrote: > Hello List! > I asked this before (with no solution), but maybe this time... I'm > trying to project a surface to the XY under a 3d cloud using

Re: [R] passing an extra argument to an S3 generic

2012-02-09 Thread ilai
You do not provide mlm.influence() so your code can't be reproduced. Or did you mean to put lm.influence() in the formals to your hatvalues.mlm ? If yes, then 1) you have a typo 2) lm.influence doesn't allow you to pass on arguments, maybe try influence.lm instead. Elai On Thu, Feb 9, 2012 at 1

Re: [R] Tukey HSD

2012-02-09 Thread ilai
Also you want " for(i in 2:ncol(mydf)) { ..." Your current setup of 1:ncol(mydf)-1 picks columns 0,1,2,...,ncol-1 (missing the last), which is not what you want... Setting i<-2 in the first line was overridden by the call to loop. Cheers On Thu, Feb 9, 2012 at 2:33 PM, peter dalgaard wrote: > >

Re: [R] Apply pmax to dataframe with different args based on dataframe factor

2012-02-09 Thread ilai
Your attempt was just overly complicated. All you needed was threshold <- c( .2 , .4 , .5 )[ df$track ] df$value <- pmax(threshold, df$value) df # desired outcome Cheers On Thu, Feb 9, 2012 at 3:56 PM, Idris Raja wrote: > # I have a dataframe in the following form: > > track <- c(rep('A', 3), r

Re: [R] how to change x-axis ?

2012-02-09 Thread ilai
plot(1:10, xaxt='n') # Don't plot the x-axis axis(1,at=c(2,5,10)) # Construct your own See ?par ?axis On Thu, Feb 9, 2012 at 2:48 PM, summer wrote: > Hi, > I want to define the x-axis in plot as 2,4,6.100 instead of the default > one. How to do that? Many thanks. > > > -- >

Re: [R] making multiple lines using qqplot

2012-02-10 Thread ilai
Melissa, par(new=T) works as many times as you use it. You don't provide data, but (assuming it is not NULL) more likely your n=500 qqplot was just obscuring the points of the n=50 plot. Reverse the order (i.e. qqplot 500 first, 50, 5 last) and see if all three are there (as there are more 500 you

Re: [R] Help needed please

2012-02-10 Thread ilai
Your script is rather inefficient with spurious cbind calls. Any particular reason not to use ?ar directly ? Call: ar.yw.default(x = simtimeseries, order.max = 4) Coefficients: 1234 1.9440 -1.9529 0.8450 -0.2154 Order selected 4 sigma^2 estimated as 15.29 To

Re: [R] Formatting Y axis.

2012-02-10 Thread ilai
yaxt='n' in ?par and ?axis are your friends. # A plot on log scale labeled with original: plot(x,log(y),yaxt='n') axis(2,at=pretty(log(y)),labels=round(exp(pretty(log(y) Works for qqnorm and boxplots, as well as other top level fun. By the way this is a FAQ. On Fri, Feb 10, 2012 at 9:43 AM

Re: [R] passing an extra argument to an S3 generic

2012-02-11 Thread ilai
You are setting a new class ("inflmlm") at the end of mlm.influence. Remove that second to last line and enjoy your new S3 method. I'm not sure, but I think it is just the new class "inflmlm" applied to inf in the formals of hatvalues.mlm confused the dispatch mechanism. You would think the error

Re: [R] Lattice 3d coordinate transformation

2012-02-11 Thread ilai
ows=F,tck=0),x=list(distance=.75)), par.box=list(lwd=NA),lwd=3) ## Beautiful ! On Sat, Feb 11, 2012 at 6:00 AM, Deepayan Sarkar wrote: > On Fri, Feb 10, 2012 at 12:43 AM, ilai wrote: >> Hello List! >> I asked this before (with no solution), but maybe this time... I'm &

Re: [R] multiple histograms from a dataframe

2012-02-12 Thread ilai
On Sat, Feb 11, 2012 at 9:10 PM, David Winsemius wrote: > > On Feb 11, 2012, at 6:25 PM, Adel ESSAFI wrote: > >> >> >> Le 11 février 2012 02:33, David Winsemius a écrit >> : >> >> On Feb 10, 2012, at 7:05 PM, Adel ESSAFI wrote: >> >> >> what can I do to draw to figures together using lattice? > >

Re: [R] Longitudinal Factor Analysis

2012-02-12 Thread ilai
?factanal There is also package sem (structural equations model) by John Fox. I'm sure there are more (maybe more fitting your situation) but these two came to mind first... Cheers On Sun, Feb 12, 2012 at 6:51 AM, Gregory Gilbert wrote: > I have a data set in the format below. I would like to

Re: [R] object not found - Can not figure out why I get this error: Error in NROW(yCoordinatesOfLines) : object 'low' not found

2012-02-12 Thread ilai
Ah, scoping rules... Consider: f <- function(x,...) plot(x,xlim=c(low,high),...) f(1:10,low=2,high=9) # "Error ... object 'low' not found " But: f <- function(x,low,high,...) plot(x,xlim=c(low,high),...) f(1:10,2,9,col=2) # beautiful red points [low,high] Sorry I can't be more specific but ne

Re: [R] best subset selection on random effects model

2012-02-13 Thread ilai
The question is where do your models come from? Passing nested models to ?anova.lme in nlme package or lme4 results in a likelihood ratio test. Are you looking for something else/more ? On Sun, Feb 12, 2012 at 8:02 PM, Tao Zhang wrote: > Hi, >     I know leaps() computes the best subset selectio

Re: [R] only 0s may be mixed with negative subscripts

2012-02-13 Thread ilai
The function you posted runs without error (on these 6 lines), but does not return anything that looks remotely like a sum, or cumsum of anything. Can you clarify what you are trying to do? I assume by "sum of every other row" you don't mean summing Time, X and Y for rows 1,3,5,..., ? For the sum

Re: [R] only 0s may be mixed with negative subscripts

2012-02-13 Thread ilai
e this helps (more...). On Mon, Feb 13, 2012 at 4:04 PM, Hasan Diwan wrote: > On 13 February 2012 14:46, ilai wrote: >> The function you posted runs without error (on these 6 lines), but >> does not return anything that looks remotely like a sum, or cumsum of >> anything. C

Re: [R] Writing R-scripts

2012-02-13 Thread ilai
It seems all you are doing in the if statements is defining functions. You need to actually "apply" them to some arguments, then you can pass results. i.e. f<- function(x,type,...){ a<- function(...){ 2* x } b<- function(...) { x^2 } if(type==1){ ret<- a(x) } if(type==2){ ret<- b(x) } ret } You

Re: [R] passing an extra argument to an S3 generic

2012-02-14 Thread ilai
. Let me know. Sorry about that "just remove the class". Had somewhat of a brain glitch when writing the E-mail and wasn't clear. Cheers On Tue, Feb 14, 2012 at 8:05 AM, Michael Friendly wrote: > On 2/11/2012 12:00 PM, ilai wrote: >> >> You are setting a

Re: [R] If (x > 0)

2012-02-14 Thread ilai
ronment from which they are called beforehand, just like the arguments. Cheers Elai. > Thanks for that info. > Take care > Mike > > -Original Message- > From: ila...@gmail.com [mailto:ila...@gmail.com] On Behalf Of ilai > Sent: Monday, February 13, 2012 6:19 PM >

Re: [R] different way for a for loop for several columns?

2012-02-14 Thread ilai
Inline On Tue, Feb 14, 2012 at 3:16 AM, Nerak T wrote: > Dear Ilai, > > > > Thanks for your answer. I'm indeed kind of a beginner in R, starting > to discover the endless possibilities in R. My goal for the moment is indeed > to get rid of the use of loops and to se

Re: [R] How to suppress the empty plots in xyplot (lattice)

2012-02-14 Thread ilai
> read ?xyplot > It takes a skip argument: >          ‘skip’: logical vector (default ‘FALSE’), replicated to be as >              long as the number of panels (spanning all pages).  For >              elements that are ‘TRUE’, the corresponding panel >              position is skipped; i.e., nothi

Re: [R] best subset selection on random effects model

2012-02-14 Thread ilai
at 11:25 AM, Tao Zhang wrote: > The models are not nested. I would like to consider all the possible > subsets. > I hope to output a table, where each row of the table indicates a best > subset of the fixed effects for a particular model size. > > Thank you, > Tao > > > 20

Re: [R] Plotting function image

2012-02-14 Thread ilai
In the absence of data coords <- expand.grid(lat=1:5,long=1:5) coords$z <- rnorm(25) Coords<- unstack(coords,z~long) image(as.matrix(Coords)) On Tue, Feb 14, 2012 at 10:36 AM, uday wrote: > I have some data set which has latitude, longitude and Z values. > I would like to plot them on global ma

Re: [R] Plotting function image

2012-02-15 Thread ilai
Inline On Wed, Feb 15, 2012 at 3:04 AM, uday wrote: > Hi , > > Thanks for reply > > My latitude and longitude contains 9-10 observations per file > when I run coords <- expand.grid(lat=1:5,long=1:5) then my computer > You don't have to run this part. As your original post did not provide

Re: [R] Filling out a data frame row by row.... slow!

2012-02-15 Thread ilai
First, in R there is no need to declare the dimensions of your objects before they are populated so couldn't you reduce some run time by not going through the double data.frame step ? > df<- data.frame() > df data frame with 0 columns and 0 rows > for(i in 1:100) for(j in 1:3) df[i,j]<- runif(1) >

Re: [R] [newbie] separating plot output from debug output

2012-02-15 Thread ilai
If you don't dev.off(), all plots will be sent to the open graphical device. That usually doesn't impact behavior of other output types: pdf(file='fooout.pdf') hist(x <- rnorm(100)) y <- sin(x) print(str(y)) cat(y,file='fooout.txt') plot(x,y) dev.off() Hope this helps On Wed, Feb 15, 2012 at 3:4

Re: [R] Defining a viewport scale in {Grid}

2012-02-16 Thread ilai
Read the Details section in ?viewport carefully. You are treating xscale/yscale as if they are xlim/ylim in base graphics. They are not. It may take some trial and error on your part to figure out how exactly this works, in general you are setting the size and location of each polygon relative to t

Re: [R] Graphing lines of different lengths

2012-02-16 Thread ilai
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. On Thu, Feb 16, 2012 at 12:42 PM, Jordan Patricia Sinclair wrote: > Hello all. > I need to graph multiple lines of different lengths on the same graph.  

Re: [R] creating series of vectors

2012-02-16 Thread ilai
# All days in years 2006 to 2009 by month in 48 (12x4) files. days <- seq(as.Date("2006/1/1"), as.Date("2009/12/31"),by="day") # one long vector out <- paste(rep(format(days,'%d%m%y'),each=2),c('aaa','bbb'),sep='_') # reformat to style month <- factor(rep(format(days,'%B%y'),each=2)) # group by

Re: [R] lmer - error message

2012-02-17 Thread ilai
I think my problem is that I can't >> incorporate the 'lake' variable in a fixed-effect interaction because it is >> only has one binary observation.  But I don't know what to do to be able to >> fit this model.  Any help would be greatly appreciated! >> -Sean > >  In principle you should be able

Re: [R] Neighbour List to Matrix

2012-02-17 Thread ilai
I think is good to know that list contain more than 60 rows with around 14000 nodes (participants). ?read.table may be unreliable for large matrices and with 14/600 you'll end up with many NA's. You might do better with nbrs<- scan('nbrs.txt',skip=1,what=list('integer','integer',double(0)))

Re: [R] foreach %do% and %dopar%

2012-02-18 Thread ilai
Marcos, Untested because you didn't provide a reproducible example but my guess, the problem is in the local assignment of MCPVMP*. The %do% worked just because it operates in the same (local) environment for all threads. I'll try to clarify with a a self contained example of sourcing a script with

Re: [R] World Heat/Rainbow Map

2012-02-19 Thread ilai
Figure 13.10 in "Lattice: Multivariate Data Visualization with R" might give you some ideas http://lmdvr.r-forge.r-project.org/figures/figures.html On Sun, Feb 19, 2012 at 9:05 AM, Lorenzo Isella wrote: > Dear All, > I would like to do the following: make a plot of the world and color a few > se

Re: [R] barplot with more than 1 variable

2012-02-19 Thread ilai
You could have found the solution in http://had.co.nz/ggplot2/geom_bar.html yourself since all help pages for ggplot refer you to the web site. But to speed things up for you, try this for starters: TUSE2 <- data.frame(country = rep(c("United States","Italy","Germany","Netherlands"),each=2), year3

[R] Fwd: bigmemory not really parallel

2012-02-20 Thread ilai
The default nstart in ?bigkmeans is 1. Try ans<-bigkmeans(data,k,nstart=8) Good luck On Mon, Feb 20, 2012 at 4:22 PM, Lishu Liu wrote: > Hi, all, > > I have a really big matrix that I want to run k-means on. > I tried: >>data <- > read.big.memory('mydata.csv',type='double',backingfile='mydata.bi

Re: [R] Time taken to process a file after a socket connection was made

2012-02-21 Thread ilai
),timeout=0) Bottom line, I have no idea what is going on except 60 sec doesn't sound right to me... Good luck Elai > > Here lies my query : Is there any kind of "*timeout*" factor which is > causing the delay? > Please share your thought. > Also do yo

Re: [R] Several densityplots in single figure

2012-02-22 Thread ilai
On Wed, Feb 22, 2012 at 8:49 AM, David Winsemius wrote: > > After going back and constructing a proper dataset, you should be passing > 'groups' into the panel function and picking it up inside panel.abline. Close, but unfortunately things get more complicated when using groups in densityplot. A

Re: [R] Installing rgl

2012-02-22 Thread ilai
On Wed, Feb 22, 2012 at 3:23 AM, aoife wrote: > Hey guys,I'm working with R version 2.14.1 (2011-12-22) on a unix machine You may be missing some openGL libraries (mesa ? ) On Ubuntu, this solved my problem of installing rgl: sudo apt-get build-dep r-cran-rgl Can't vouch for any future complicat

Re: [R] line width in legend of interaction.plot

2012-02-22 Thread ilai
On Wed, Feb 22, 2012 at 11:37 AM, Matthias Gondan wrote: > Dear R developers, > > The following command produces an interaction plot with lwd=2. > > interaction.plot(c(1, 2, 1, 2), c(1, 1, 2, 2), 1:4, lwd=2) > > In the legend, however, lwd seems to be 1, which does not seem > to be intended behavi

Re: [R] tapply for enormous (>2^31 row) matrices

2012-02-22 Thread ilai
On Tue, Feb 21, 2012 at 4:04 PM, Matthew Keller wrote: > X <- read.big.matrix("file.loc.X",sep=" ",type="double") > hap.indices <- bigsplit(X,1:2) #this runs for too long to be useful on > these matrices > #I was then going to use foreach loop to sum across the splits > identified by bigsplit Ho

Re: [R] Lattice and horizontally stacked density plots

2012-02-22 Thread ilai
The plot you referred to depends on packages flowViz and flowCore from R-bioconductor. With lattice alone you can easily get all curves on the same level: densityplot(~ val | factor(id2), groups=factor(id1),data=a_df,pch='|') But if that doesn't do it for you, you could write your own panel functi

Re: [R] Advice on exploration of sub-clusters in hierarchical dendrogram

2012-02-23 Thread ilai
See inline On Thu, Feb 23, 2012 at 8:54 AM, kosmo7 wrote: > Dear R user, > In other words, I am trying to obtain/read the sub-clusters of a specific > cluster in the dendrogram, by isolating a specific node and exploring > locally its lower hierarchy. To explore or "zoom in" on elements of z yo

Re: [R] help with winbugs glm

2012-02-23 Thread ilai
Adan, How many levels does Depth have? my wild guess: 3 and your bugs model is not identifiable. Second, I think you may have a critical error in the way you formatted the data for the bugs model. From your code it looks like you are just using the factor Depth and not a design matrix of dummy var

Re: [R] cor() on sets of vectors

2012-02-23 Thread ilai
On Thu, Feb 23, 2012 at 3:24 PM, Bert Gunter wrote: > Use 1:n as an index. > > e.g. > sapply(1:n, function(i) cor(x[,i],y[,i])) ## sapply is a good solution (the only one I could think of too), but not always worth it: # for 100 x 1000 x <- data.frame(matrix(rnorm(10),nc=1000)) y <- data.f

Re: [R] Advice on exploration of sub-clusters in hierarchical dendrogram

2012-02-24 Thread ilai
Inline: On Thu, Feb 23, 2012 at 8:23 PM, R. Michael Weylandt wrote: > Inline: > > On Feb 23, 2012, at 6:20 PM, kosmo7 wrote: > >> Dear Elai, >> thank you very much for your suggestion. I tried cutting the dendrogram >> instead of the hclust tree with: >> clusters<-cut(x, h=1.6) >> >> but then w

Re: [R] help with winbugs glm

2012-02-24 Thread ilai
gt; > 0 0 4 2 1.81 > > 1 0 1.75 3 1.5 > > 0 1 1.84375 3 1.33 > > 1 0 2 3 1.66 > > 1 0 2.25 3 0.73 > > 0 0 2.5 3 1.6 > > 0 1 3 3 1.99 > > 1 0 3.25 3 1.09 > > 1 0 4.25 3 1.54 > > 1 0 5 3 1.6 > > 1 0 5.5 3 1.73 > > END > > > > &g

Re: [R] tcl tk command function with arguments ??

2012-02-24 Thread ilai
On Fri, Feb 24, 2012 at 12:58 AM, Alexander wrote: > I would like to know if its possible to use a function with arguments as a > command in tcl tk. Yes I think > this is due to the fact that the PressedOK(3) was the last call of the > function, but I don't understand why all the other button

Re: [R] data frame manipulation with conditions

2012-02-24 Thread ilai
On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading wrote: > Dear list, > > n00b question, but still can't find any easy answer. > > Here is a df: > >> df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4)) # No, your y is a factor str(df) 'data.frame': 4 obs. of 2 variables: $ x: Factor w/ 3 leve

Re: [R] data frame manipulation with conditions

2012-02-24 Thread ilai
nlap. > > Arnaud Gaboury > > A2CT2 Ltd. > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of ilai > Sent: vendredi 24 février 2012 20:14 > To: A2CT2 Trading > Cc: r-help@r-project.org > Subject:

Re: [R] Optim() package restriction

2012-02-24 Thread ilai
On Fri, Feb 24, 2012 at 12:18 PM, nserdar wrote: > Hi > > I need a "phi" restriction in my code. That is   "0 > How can I do that ? > init.par<-c(1,1,1,1) > estimate<- optim(init.par,Linn,gr=NULL,method= "BFGS", hessian=FALSE,control > = list(trace=1)) > You want method "L-BFGS-B" not "BFGS". Se

Re: [R] tcl tk command function with arguments ??

2012-02-24 Thread ilai
On Fri, Feb 24, 2012 at 5:03 PM, peter dalgaard wrote: > > > Now that's just weird... Firstly, it has nothing to do with sapply vs. for > loops. It just works because you are inserting yet another function > environment. Thank you Peter, that makes more sense. As you can probably imagine, first

Re: [R] Optim() package restriction

2012-02-25 Thread ilai
On Fri, Feb 24, 2012 at 4:03 PM, nserdar wrote: > I did it like above  but got an error message. > >> estimate<- optim(init.par,Linn,gr=NULL,method= "L-BFGS-B", >> hessian=FALSE,control = >> list(trace=1),lower=c(0,-Inf,Inf,Inf),upper=c(1,Inf,Inf,Inf)) Your lower bound for parameters 3,4 needs to

Re: [R] Finding name of variable supplied as function argument

2012-02-25 Thread ilai
On Sat, Feb 25, 2012 at 12:53 PM, Ted Harding wrote: > I have defined > a function med3x3() such that, given vectors X,Y, > med3x3(X,Y) returns a 3x3 table ... > But I'd like to simply be able to pick up, within the function, > the names of the variables that were used as arguments in the > func

Re: [R] Matrix problem to extract animal associations

2012-02-27 Thread ilai
set.seed(1) (DFid <- data.frame( x = sample(1:20,10), y = sample(1:20,10), IDs = sapply(1:10,function(i) paste("ID",i,sep="" require(spdep) coordinates(DFid) <- ~x+y coords <- coordinates(DFid) dnn4 <- dnearneigh(DFid,0,4) summary(dnn4) plot(DFid) plot(dnn4,coords,add=T,col=2) nb2mat(dnn4,

Re: [R] Need advice on GLM

2012-02-27 Thread ilai
On Mon, Feb 27, 2012 at 1:44 AM, Christofer Bogaso wrote: >  Here I was expecting those 2 approaches should give exactly same result > (i.e. same estimates and same SE), which is not the case. Can somebody > point me what I am missing here? > The vector of weights as described in ?glm which from

Re: [R] group calculations with other columns for the ride

2012-02-28 Thread ilai
aggregate(val~lvls+nm,data=x,FUN='median') On Tue, Feb 28, 2012 at 4:43 PM, Ben quant wrote: > Hello, > > I can get the median for each factor, but I'd like another column to go > with each factor. The nm column is a long name for the lvls column. So > unique work except for the order can get

Re: [R] How to replace the values in a column

2012-02-28 Thread ilai
Hannah, If Gen is a factor you can simply build the new factor "on top" of it: dataframe$Gen<- factor( c('Wynda' , 'A_2' , 'B_1' , 'Wynda' , 'Wynda' , 'OP1_5')[Gen] ) Just make sure the replacement labels are in the same order as levels(Gen). Cheers On Tue, Feb 28, 2012 at 8:39 PM, hannahmaohua

Re: [R] ts.plot and x axes customization

2012-02-28 Thread ilai
On Tue, Feb 28, 2012 at 12:57 PM, Jochem Schuster wrote: >   ts.plot(series1, series2, main=main, xlab=xlab, ylab=ylab, col=c("green", >   "red", "blue"), lwd=2)   What I've tried before is deleting the X axes via gpars=list(xaxt="n") in >   the ts.plot-code. But after that I was not aible to a

Re: [R] ts.plot and x axes customization

2012-02-29 Thread ilai
On Wed, Feb 29, 2012 at 1:56 AM, Jochem Schuster wrote: > Hello, > > thank you very much for your answer. In the following, I will provide my > recent code and try to explain again: > > series1 = ts(x$france start=c(2000,1), frequency=4) > series2 = ts(x$germany, start=c(2000,1), frequency=4) > ti

Re: [R] Quantile scores as dependent variables.. an R and general method question

2012-02-29 Thread ilai
On Tue, Feb 28, 2012 at 3:54 PM, Rob James wrote: > I have a dataset that does not include native scores, but only serial > quantile rankings for a set of units. > > Clearly these observations are dependent (in that you can't alter one > observation without also altering others). > > Are there met

Re: [R] Quantile scores as dependent variables.. an R and general method question

2012-02-29 Thread ilai
r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf > Of ilai [ke...@math.montana.edu] > Sent: Wednesday, February 29, 2012 1:30 PM > To: Rob James > Cc: r-help@r-project.org > Subject: Re: [R] Quantile scores as dependent variables.. an R and general > metho

Re: [R] barplots of several variables with different number of categories

2012-03-01 Thread ilai
Jon, You could create new variables with the combined levels just for the purpose of plotting. Assume I have data.frame bpt str(bpt) 'data.frame': 12 obs. of 2 variables: $ V1: Factor w/ 3 levels "low","med","high": 1 1 1 1 2 2 2 2 3 3 ... $ V2: Factor w/ 6 levels "1","2","3","4",..: 1 1 2 2 3

Re: [R] Displaying data in Trellis

2012-04-18 Thread ilai
On Wed, Apr 18, 2012 at 8:45 AM, slavrenz wrote: I would like to display with the xyplot() function > for several states. I will have a total of 6 plots, I need to plot the > points of one of the states in a different color than all the rest, such > that they can be more easily referenced in a p

Re: [R] how to plot separate lm ablines on the same xyplot by group

2012-04-18 Thread ilai
On Wed, Apr 18, 2012 at 2:07 PM, Louis Plough wrote: > If you could lead me to an example with code, that would help me figure out > how to do it for my function The states example in ?xyplot uses groups and subscripts in a panel function >> I read it, but I guess I don't quite understand which

Re: [R] Displaying data in Trellis

2012-04-19 Thread ilai
On Thu, Apr 19, 2012 at 2:55 AM, ce41188 wrote: > Thank you for the reply. > > The more I look at this, the more confused I become. I was wondering if you > could walk me through this a little more in detail, in particular the panel > method function of doing things. It may be obvious to many, but

[R] Fwd: User defined panel functions in lattice

2012-04-19 Thread ilai
On Thu, Apr 19, 2012 at 2:30 AM, Duncan Mackay wrote: > Hi > >  xyplot(y ~x|Farm,xx, >         groups = Padd, >         panel = panel.superpose, >         panel.groups=function(x,y, ...){ >                        panel.Locfit(x,y,...) >                        panel.xyplot(x,y,...) >              

Re: [R] Fwd: User defined panel functions in lattice

2012-04-20 Thread ilai
Duncan, First off, I admit it is not clear to me what you are trying to achieve and more importantly, why? by "why" I mean 1) I don't see the advantage of writing one general panel function for completely different situations (one/multiple smoothers, grouping levels etc.) 2) your intended result as

Re: [R] Fwd: User defined panel functions in lattice

2012-04-20 Thread ilai
Oops - that is "reply all" On Fri, Apr 20, 2012 at 5:29 PM, David Winsemius wrote: > > I'm a bit puzzled by this exchange. I know there is a 'panel.locfit', but > you two are spelling it differently. Can you explain why you are doing so? > Hi David, Thanks for stepping in. panel.Locfit is the OP'

Re: [R] Fwd: User defined panel functions in lattice

2012-04-20 Thread ilai
On Fri, Apr 20, 2012 at 8:15 PM, David Winsemius wrote: > > Another puzzle. In the original posting there was this segment: > --- > > but gives an error message without par.settings if i want to add >                       panel.Locfit(x,y,nn= 0.9,lwd = c(1,2,3), ...) > > Error using packet 1 > fo

Re: [R] Remove top/right border from lattice plots

2012-04-24 Thread ilai
You need to do a little more work to add the components you want "back in". I think you want something like: xyplot( Sepal.Length ~ Petal.Length, auto.key=T, data=iris, par.settings = list(axis.line = list(col = 0)),scales=list(col=1,tck=c(1,0)), panel=function(...){ lims <- current.panel.lim

Re: [R] automating a script to read a file

2012-04-24 Thread ilai
On Tue, Apr 24, 2012 at 2:09 PM, wrote: > library(latticeExtra) >> doubleYScale(hist("mydata", breaks=20, prob=T,  xlim=c(-100, 2000), > plot.spdf(x), use.style=FALSE) > > This does not work as doubleYScale expects histogram and densityplot,  and > I'd like to use the plot.spdf routine in its pl

Re: [R] automating a script to read a file

2012-04-24 Thread ilai
le to you. Best > > Steve > > On Apr 24, 2012 7:45 PM, "ilai" wrote: >> >> On Tue, Apr 24, 2012 at 2:09 PM,   wrote: >> >> > library(latticeExtra) >> >> doubleYScale(hist("mydata", breaks=20, prob=T,  xlim=c(-100, 2000),

Re: [R] Create new Vector based on two colums

2012-04-25 Thread ilai
On Wed, Apr 25, 2012 at 6:14 AM, Patrick Hausmann wrote: > Hello, > > I am trying to get a new vector 'x1' based on the not NA-values in column > 'a' and 'b'. I found a way but I am sure this is not the best solution. So > any ideas on how to "optimize" this would be great! If by optimize you mea

Re: [R] error bars for a barchart

2012-05-01 Thread ilai
Hi, I think the issue is not "respecting the groups" but finding the x-location of the center of bars in panel.barchart(groups,...). Don't know about the memisc package, but doesn't look like it provides an easy solution. This is how I do it: http://www.mail-archive.com/r-help@r-project.org/msg1622

Re: [R] error bars for a barchart

2012-05-01 Thread ilai
Thank you for your example. I only skimmed it, but since both solutions use nlevels and box.ratio it is no surprise we end up at the same place (although I do think your g-median is nicer than my 3/4). Thing is, I wouldn't call either of these "simple"... would be nice if one could just query the

Re: [R] Lattice side by side boxplots with average

2012-05-08 Thread ilai
On Tue, May 8, 2012 at 9:32 AM, maxbre wrote: > and then with the superposition of relative average values to the boxplots, > i.e. something like: > > panel.points(…, mean.values, ..., pch = 17) Almost. You need to give panel.points the new x, and make sure the right mean.values go to the right

Re: [R] Lattice: Add abline to Single Value qqmath() Plot

2012-05-15 Thread ilai
On Tue, May 15, 2012 at 4:19 PM, Rich Shepard wrote: > On Tue, 15 May 2012, David L Carlson wrote: > > David, > >  I have 130 plots to produce (30 chemicals un-transformed and three > transformations). The R console insists that I retype each of the 6 lines > (adding a prepanel.qqmathline line) ea

Re: [R] Manually modifying an hclust dendrogram to remove singletons

2012-05-24 Thread ilai
Can't put my finger on it but something about your idea rubs me the wrong way. Maybe it's that the tree depends on the hierarchical clustering algorithm and the choice on how to trim it should be based on something more defensible than "avoid singletons". In this example Hawaii is really different

Re: [R] glm(weights) and standard errors

2012-05-25 Thread ilai
I'm confused (I bet David is too). First and last models are "the same", what do SE's have to do with anything ? naive <- glm(extra ~ group, data=sleep) imputWrong <- glm(extra ~ group, data=sleep10) imput <- glm(extra ~ group, data=sleep10,weights=rep(0.1,nrow(sleep10))) lapply(list(naive,imputWr

Re: [R] lattice: add a marginal histogram on top of the colorkey of a levelplot?

2012-05-29 Thread ilai
?plot.trellis. In general something like mlp<- levelplot(... mhist<- histogram(... plot(mlp,split=c(1,2,1,2),more=T) plot(mhist,split=c(1,1,1,2),more=F) You will need to do some work on the padding and layout widths to get the distances right (I assume the key is to be the "x-axis" of the histogr

Re: [R] Separate Array Variable Content

2012-05-30 Thread ilai
If you haven't done so you *must* read an Introduction to R. The only reason this is a problem is Myarray is a character string, not a function or expression to be evaluated. I think this will get you what you want though: # In the future use the output of ?dput to provide data to this list (MyMa

<    1   2