[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

[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

[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 =

[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] 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.

Re: [R] plot of all.effects object

2008-09-11 Thread David Afshartous
(); (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 On Thu, 11 Sep 2008 15:54:25 -0400 David Afshartous [EMAIL PROTECTED] wrote: All, I'm trying to plot

[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

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

2008-08-27 Thread David Afshartous
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 guess is that it has something to do with the number of significant digits being represented, but perhaps

[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

[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 =

[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

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 subsequent plots done on subsets to maintain the color assignments from the original plot. This works

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

2008-07-09 Thread David Afshartous
), par.settings = list(superpose.line = list(lty = c(2,3,4), col=c('black', 'green', 'blue') ) ) ) On 7/9/08 3:13 PM, David Afshartous [EMAIL PROTECTED] wrote: On 7/9/08 1:07 PM, Deepayan Sarkar [EMAIL PROTECTED] wrote: On 7/9/08, David Afshartous [EMAIL PROTECTED

[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

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 xyplot that is employing panel.text. Specifically, I often change the default

[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

[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

[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: All, I have a long vector that contains

[R] Connecting lines across missing data points, xyplot

2008-06-26 Thread David Afshartous
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 = c(10, NA, NA, 12, 11, 10,NA

[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

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

2008-06-16 Thread David Afshartous
? On Mon, Jun 16, 2008 at 11:30 AM, David Afshartous wrote: 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

[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,...){

[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
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous Sent: Tuesday, May 20, 2008 9:50 AM To: r-help@r-project.org Subject: [R] Alignment of axes intersection All, Very basic question I can't seem to find the answer to: plot(0

[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

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 a

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

2008-03-04 Thread David Afshartous
'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. David Afshartous wrote: Okay, I see that default.units is set to npc and hence the behavior I mentioned. Looking at ?unit, I see

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

2008-02-29 Thread David Afshartous
. -- Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous Sent: Thursday, February 28, 2008 1:15 PM To: r-help@r-project.org Subject: [R] Replacing plot symbols w/ subject IDs in xyplot() All, How does

[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 =

[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

[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] 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

[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

[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

[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

[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

[R] Rounding of lme coefficients: Mac vs Windows

2007-10-06 Thread David Afshartous
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 utils datasets methods base other attached

[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

[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