[R] Question about parse and expression

2007-06-06 Thread Nitin Jain
Dear R-users,

In the following example, I would like to see my ylabel as: beta[3] * x[3] + 
epsilon (where beta and epsilon are replaced by their mathematical symbols).

Please advise.

Thanks.

Nitin


i - 3

ee - expression(beta[i] * x[i] + epsilon)

xyplot(1:10~ 11:20,
   ylab = parse(text=ee)
   )
   



 

8:00? 8:25? 8:40? Find a flick in no time

__
R-help@stat.math.ethz.ch 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] separate y-limits in xYplot panels

2007-05-30 Thread Nitin Jain
Hello,

I would like to get the scales of y-axes dependent only on the data points in a 
particular panel. Have attached a test example below.
When using 'relation=free', it does not make the scales 'free', however when 
using 'relation=sliced', I get a warning Explicitly specified limits ignored 
in: limitsFromLimitlist(have.lim = have.ylim, lim = ylim, relation = 
y.relation, (although in this particular case, I get the desired result, but 
in my real data, I do not get the free y-scale for each panel). Can you please 
let me know what should be correct syntax?

Thanks.
-Nitin

library(Hmisc)

test1 - data.frame(
y = c(rnorm(33), rnorm(33, mean=10),
rnorm(34, mean=100)),
x = 1:100,
f = factor(c(rep(a, 33), rep(b, 33), rep(c, 34))),
g = factor(sample(LETTERS[1:2], size=100, replace=TRUE))
)


CI - rnorm(100)
lb - test1$y - CI
ub - test1$y + CI


xYplot(Cbind(y, lb,ub )~x|f,
   groups=g,
   scales = list(relation=free), ## Changing it to sliced gives warning
   data=test1)

 




 

Don't pick lemons.

__
R-help@stat.math.ethz.ch 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] separate y-limits in xYplot panels

2007-05-30 Thread Nitin Jain
Thanks Sundar and Gabor for your prompt help.

Sundar - Even after changing the line to scales = list(y = list(relation = 
free)), I do not get the free scales in my test code (below), and relation 
=sliced still gives warning.

Gabor - I'll try using code as demo(intervals) suggests.

Best,
Nitin



Nitin Jain said the following on 5/30/2007 8:12 AM:
 Hello,


I would like to get the scales of y-axes dependent only on the data
points in a particular panel. Have attached a test example below.

When using 'relation=free', it does not make the scales 'free',
however when using 'relation=sliced', I get a warning Explicitly
specified limits ignored in: limitsFromLimitlist(have.lim = have.ylim,
lim = ylim, relation = y.relation, (although in this particular case,
I get the desired result, but in my real data, I do not get the free
y-scale for each panel). Can you please let me know what should be
correct syntax?

 Thanks.
 -Nitin

 library(Hmisc)

 test1 - data.frame(
 y = c(rnorm(33), rnorm(33, mean=10),
 rnorm(34, mean=100)),
 x = 1:100,
 f = factor(c(rep(a, 33), rep(b, 33), rep(c, 34))),
 g = factor(sample(LETTERS[1:2], size=100, replace=TRUE))
 )


 CI - rnorm(100)
 lb - test1$y - CI
 ub - test1$y + CI


 xYplot(Cbind(y, lb,ub )~x|f,
groups=g,
scales = list(relation=free), ## Changing it to sliced gives warning
data=test1)



You want 


HTH,


--sundar 




   
Choose
 the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.

__
R-help@stat.math.ethz.ch 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] xyplot key using grid.text

2007-05-15 Thread Nitin Jain
Hello,


I am trying to print the lm 
coefficients using grid graphs (code below), and am getting all the 
coefficients 
on top of each other.

 

My aim is to put them as legend, 
showing both coefficients and mean values separated by colors as shown in 
xyplot.
 

testData - data.frame(f1 = 
factor(rep(LETTERS[1:5], each = 20)),

   f2 = 
factor(rep(letters[6:7], 50)),

   x1 = 
rnorm(100, mean = 2, sd = 1),

   x2 = 
rnorm(100, mean = 10, sd = 4),

   x3 = 
rnorm(100, mean = 4, sd = 3),

   y = (1:50) + 
rnorm(50, sd = 3) + rep(c(-2, 2), 50))

 

 

grid.newpage()

grps - factor(testData[, 
f2])

xyplot( y ~ 
x1|f1,

   
groups=grps,

   panel=function(x, y, ...) 
{

 panel.superpose(x, y, 
...)

   
},

   panel.groups = function(x, y, 
...) {

 fit.lm - 
lm(y~x)

 coef.fit - 
round(coef(fit.lm)[-1], 2)

 avg.y - round(mean(y), 
2)

 
panel.abline(fit.lm)

 panel.xyplot(x, y, 
...)

 ## Add lm 
coefficients:

 grid.text(x= unit(0.1, 
npc),

   y= unit(seq(0.1, 
length= length(levels(grps)), by =0.1),

 
npc),

   label = 
paste(expression(beta), =, coef.fit)


   ),
## Add mean values: (note that mu is not shown as symbol)

grid.text(x= unit(0.1, 
npc),


   y= unit(seq(0.9, 
length= length(levels(grps)), by =-0.1),


 
npc),


   label = 
paste(expression(mu), =, avg.y)



   ),




   
},

   ##  Key 

   key = 
simpleKey(levels(grps),

 columns = 
2,

 space = 
bottom,

 points = 
TRUE,

 lines = 
TRUE

 
),

   ## 
grid.legend()

   data= 
testData

 )

 



Thanks.

-NJ



  

Park yourself in front of a world of choices in alternative vehicles. Visit the 
Yahoo! Auto Green Center.

__
R-help@stat.math.ethz.ch 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.