[R] Connecting lines across missing data points, xyplot

2008-06-26 Thread David Afshartous
ow to rectify this? Cheers, David Afshartous library(lattice) ## the data junk = data.frame( Visit = as.factor(rep(seq(1,5), 2)), Drug = rep(c("D", "P"), each = 5), Aldo = c(13, NA, NA, 15, 14, 12, NA, NA, 14, 13), SE.Aldo = c(3, NA, NA, 3, 3, 2, NA, NA, 2, 2), lower.ci.Aldo =

[R] Switching entries in vector in by groups of two

2008-06-27 Thread David Afshartous
All, I have a long vector that contains an even number of entries. I'd like to switch the 1st and 2nd entry, the 3rd and 4th, and so on, without writing a loop. This code works: X = c(8, 10, 6, 3, 20, 1) index = c(2,1,4,3,6,5) X[index] But for a long list is there a way to generate the index?

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread David Afshartous
Thanks Henrique, Marc, and Gabor! On 6/27/08 10:17 AM, "Henrique Dallazuanna" <[EMAIL PROTECTED]> wrote: > Try this: > > ave(X, rep(1:(length(X)/2), each = 2), FUN=rev) > > On Fri, Jun 27, 2008 at 11:11 AM, David Afshartous <[EMAIL PROTECTED]> > wrote:

[R] auto.key in xyplot in conjunction with panel.text

2008-07-02 Thread David Afshartous
All, I can't seem to get auto.key to work properly in an xyplot that is employing panel.text. Specifically, I often change the default grouping colors then use auto.key accordingly, but for some reason the same functionality isn't working for this different type of plot. Any help much apprecia

Re: [R] auto.key in xyplot in conjunction with panel.text

2008-07-03 Thread David Afshartous
Thanks! That works perfect. On 7/2/08 6:45 PM, "Deepayan Sarkar" <[EMAIL PROTECTED]> wrote: > On 7/2/08, David Afshartous <[EMAIL PROTECTED]> wrote: >> >> >> All, >> >> I can't seem to get auto.key to work properly in an xyp

[R] Installation of packages via GUI, Mac OS X

2008-07-03 Thread David Afshartous
All, I'm running R v2.7.1 on Mac OS X. When I go to the R package installer GUI, I am not prompted to select a repository. The usual screen is there but the columns for package, installed version, and repository version are all populated via blank entries. If I select "Get List" the error bel

[R] aggregate() function and na.rm = TRUE

2008-07-08 Thread David Afshartous
All, I've been using aggregate() to compute means and standard deviations at time/treatment combinations for a longitudinal dataset, using na.rm = TRUE for missing data. This was working fine before, but now when I re-run some old code it isn't. I've backtracked my steps and can't seem to find

[R] Auto.key colors maintained when subsetting

2008-07-09 Thread David Afshartous
All, I'm plotting points and lines for various groups. I'd like subsequent plots done on subsets to maintain the color assignments from the original plot. This works fine, but the key for the subset doesn't maintain the correspondence. One solution is to reprint the entire key, but this is und

Re: [R] Auto.key colors maintained when subsetting

2008-07-09 Thread David Afshartous
On 7/9/08 1:07 PM, "Deepayan Sarkar" <[EMAIL PROTECTED]> wrote: > On 7/9/08, David Afshartous <[EMAIL PROTECTED]> wrote: >> >> >> All, >> >> I'm plotting points and lines for various groups. >> I'd like subseque

Re: [R] Auto.key colors maintained when subsetting

2008-07-09 Thread David Afshartous
panel.groups = panel.ci, type="b", auto.key = list(space = "top", text = levels(junk$Group), points = FALSE, lines = TRUE, columns=3), par.settings = list(superpose.line = list(lty = c(2,3,4), col=c('black', '

[R] Pairs() function: selective changing of ylim; use of key

2008-07-25 Thread David Afshartous
All, Two questions RE scatterplot matrices produced via pairs() function: 1) Is it possible to selectively change the ylim of one of the subplots? 2) Is a key allowed? I don't seem to be able to insert a manual key. Code below: dat = data.frame(Hour= rep(c(0:3), 4), Y1 = rnorm(16,1), Y2 = rno

[R] Axes in perspective plot - persp()

2008-07-30 Thread David Afshartous
All, I'm making some plots with the persp() function and am having trouble sorting out the following: - How does one avoid the axes label overlapping the tick values? - Is doesn't seem possible to independently control the number of ticks of the x,y, and z-axes, e.g., I'd like say only 4 ticks

[R] Significant digits for checking values of variable?

2008-08-27 Thread David Afshartous
All, I'm witnessing some strange behavior when checking the values of one of my variables. My guess is that it has something to do with the number of significant digits being represented, but perhaps not as my variable was created from other variables that only had one decimal place. See below.

Re: [R] Significant digits for checking values of variable?

2008-08-27 Thread David Afshartous
lt;[EMAIL PROTECTED]> wrote: > FAQ 7.31 > > On Wed, Aug 27, 2008 at 11:51 AM, David Afshartous > <[EMAIL PROTECTED]> wrote: >> >> All, >> >> I'm witnessing some strange behavior when checking the values of one of my >> variables. My

[R] plot of all.effects object

2008-09-11 Thread David Afshartous
All, I'm trying to plot an all.effects() object, as shown in the help for all.effects and also Crawley's R book (p.178, 2007). The data has a repeated measures structure, but I'm using all.effects for the simple lm() fit here. Below is a reproducible example that yields the error message. fm.

Re: [R] plot of all.effects object

2008-09-11 Thread David Afshartous
y one high-order term in > your model, so it's not necessary to use all.effects(); (2) if you > plot(fm.effects) (i.e., without specifying the term to plot) you'll be > presented with a menu, in this instance with only one choice. > > I hope this helps, > John > >

[R] Using sub to get captions in barplots

2008-09-30 Thread David Afshartous
All, I've been using "sub" (subtitle) instead of "main" such that captions are below figures produced by xyplot. This works fine and captions are on a single line. However, when I try this for bar plots with error bars (altering the error.bars function form Crawley's The R Book, see below), the

[R] Binom.test, vector input

2008-10-09 Thread David Afshartous
All, Is it possible to use binom.test with vector input for only one of the arguments? I was thinking that this would possibly work with sapply but then it seems that the binom.test function would have to be re-written to supply defaults for all other arguments. set.seed(101) sim.x = rbinom(100

[R] Adding points on top of lines in xyplot

2007-11-20 Thread David Afshartous
All, I'm trying to make a basic plot: data points superimposed upon the a line connecting the points w/ a different color. Example below doesn't work as the first xyplot call doesn't remain. Suggestions? David Hour = c(NA,1,2,3,4) y = c(2,2,3,2,1.5) xyplot(y ~ Hour, xlab = list("Hour", font

[R] Wireframe graph: black and white shading instead of color

2007-11-29 Thread David Afshartous
All, The code below produces a color 3D graph. I'd like to make it black and white shading. I tried setting col.regions to FALSE but this just made it completely white. I want the graph to look exactly as is, except black (or grey) and white shading. Is this possible? Cheers, David p.list

[R] Alternating numbers in rep()

2008-01-24 Thread David Afshartous
All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: > unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this g

[R] Alignment of axes intersection

2008-05-20 Thread David Afshartous
All, Very basic question I can't seem to find the answer to: plot(0:10, 0:10) The axes intersection is not aligned at (0,0) in the lower left. How does one force this? I searched for graphical parameters under par(graphics) but can't seem to find it. Thanks! David ___

Re: [R] Alignment of axes intersection

2008-05-20 Thread David Afshartous
Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > [EMAIL PROTECTED] > (801) 408-8111 > > > >> -----Original Message- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous >> Sent: Tuesday, May 20, 2008

[R] aggregate() function, strange behavior for augmented data

2008-06-16 Thread David Afshartous
All, I'm re-running some analysis that has been augmented with additional data. When I use the exact same code for the augmented data, the behavior of the aggregate function is very strange, viz., one of the resulting variables is now coded as a factor while it was coded as numeric for the origi

Re: [R] aggregate() function, strange behavior for augmented data

2008-06-16 Thread David Afshartous
bably ) used read.table to read in junk but you didn't use > that > options when you used read.table to read in junk1 ? > > > On Mon, Jun 16, 2008 at 11:30 AM, David Afshartous wrote: > >> All, >> >> I'm re-running some analysis that has been augment

[R] Error bars within xyplot, panel = function(x,y, ....)

2008-06-16 Thread David Afshartous
All, I'm trying to adapt some code provided by Deepayan Sarkar from a previous thread (https://stat.ethz.ch/pipermail/r-help/2005-October/081571.html) on this topic. ## This code produces a graph w/o error bars: xyplot(Y ~ Hr, data, groups=DRUG, panel=function(x,y,...){ panel.x

[R] Extracting level-1 variance from lmer()

2008-02-05 Thread David Afshartous
All, How does one extract the level-1 variance from a model fit via lmer()? In the code below the level-2 variance component may be obtained via subscripting, but what about the level-1 variance, viz., the 3.215072 term? (actually this term squared) Didn't see anything in the archives on this.

[R] Stratifying level-1 variance with lmer()

2008-02-05 Thread David Afshartous
All, I've fit some models via lme() and now I'm trying to fit similar models with lmer() for some simulations I'm running. The model below (fm1) has an intercept variance that depends on treatment group. How would one accomplish a similar stratification for the level-1 variance, i.e., the with

[R] Extending curve() function; 2D function plot with arguments

2008-02-07 Thread David Afshartous
All, I have a simple function below that defines a 2-dimensional curve: n.j = 4; sigma.y = 1.2; sigma.a = 2.2; y.bar.j = 8.1; mu.a = 4.4 alpha.j.fun <- function(sigma.a) { alpha.j = ((n.j/sigma.y^2)*y.bar.j + (1/sigma.a^2)*mu.a)/(n.j/sigma.y^2 + 1/sigma.a^2 ) alpha.j} The parameters

[R] Subsetting within xyplot()

2008-02-26 Thread David Afshartous
All, I'm having problems w/ a simple attempt to subset an xyplot. The first plot below is a plot of y versus x for certain values of a third categorical variable z. Now I'd like to further restrict this to certain values of variable y. Neither of the two attempts below work. Any suggestions m

[R] Replacing plot symbols w/ subject IDs in xyplot()

2008-02-28 Thread David Afshartous
All, How does one replace plot symbols with say subject IDs when using xyplot? Or superimpose them next to plot symbols? I searched the archives under various key words but haven't had much. Any suggestions or links much appreciated. Sample code below. David junk.frm = data.frame(ID =

Re: [R] Replacing plot symbols w/ subject IDs in xyplot()

2008-02-29 Thread David Afshartous
just wish to plot them > next, remove the type="n" specification and just offset the x's in text a > hair. > > -- Bert Gunter > Genentech > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of David Afshart

[R] (x,y) coordinates for grid.text()

2008-03-04 Thread David Afshartous
All, When using grid.text it seems my supplied (x,y) coordinates are being plotted only in npc (normalized parent coordinates) where (.5,.5) is the center of the graph. How do I allow (x,y) to be coordinates corresponding to the (x,y) values in the graph? The examples in ?grid.text seem to do

Re: [R] (x,y) coordinates for grid.text()

2008-03-04 Thread David Afshartous
Okay, I see that default.units is set to "npc" and hence the behavior I mentioned. Looking at ?unit, I see the description of various units but it isn't clear which one I need to select to achieve the result I specified earlier. Maybe I'm missing something very basic, but I assume there must be

Re: [R] (x,y) coordinates for grid.text()

2008-03-04 Thread David Afshartous
gt; You want "native" coordinates. But since you are using lattice (built > 'on top' of grid), you probably need some additional info, like the name > of the viewport you want to write to I assume(?), but I can't help you > with that part. > > &

[R] ldBands (Hmisc)

2008-10-13 Thread David Afshartous
All, I'm getting the same error message as that discussed in a previous post (Feb 3, 2006). The reply to that post was to insure that the ld98 program was in the system path (as also suggested in the help on ldBands). I have done this but this does not change the result. Any advice much apprec

[R] Loop avoidance in simulating a vector

2008-10-16 Thread David Afshartous
All, I'd like to simulate a vector that is formed from many distinct distributions and avoid a loop if possible. E.g, consider: mu = c(1, 2, 3) sigma = c(1, 2, 3) n = c(10, 10, 10) And we simulate a vector of length 30 that consists of N(mu[i], sigma[i]) distributed data, each of length n[i]

[R] Multiple R sessions, Mac version

2007-09-13 Thread David Afshartous
Hello all, I've just switched to running R 2.5.1 on a Mac 0S X 10.4.1 platform. I can't seem to find how to run simultaneous R sessions. Didn't see anything in the archives on this or under the R file menu. Thanks! David __ R-help@r-project.org maili

[R] Multiple R sessions, Mac version

2007-09-13 Thread David Afshartous
Hello all, I've just switched to running R 2.5.1 on a Mac 0S X 10.4.1 platform. I can't seem to find how to run simultaneous R sessions. Didn't see anything in the archives on this or under the R file menu. Thanks! David __ R-help@r-project.org maili

[R] Rounding of lme coefficients: Mac vs Windows

2007-10-06 Thread David Afshartous
t see this in the archives. Thanks, David Afshartous > sessionInfo() R version 2.5.1 (2007-06-27) i386-apple-darwin8.9.1 locale: en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] "stats" "graphics" "grDevices" &

[R] Basic plot question: Figure 1.1 Pinheiro & Bates

2007-10-12 Thread David Afshartous
All, Sorry for overly simplistic question, but I can't seem to remember how to create the basic plot shown in Figure 1.1 of Pinheiro & Bates (2004; p.4). The y-axis delineates a factor (Rail) while the x-axis displays the distribution of a continuous variable (time) according to each level of the f