Re: [R] Plotting lines to sets of points

2007-09-08 Thread Jim Price
# Create a matrix of ball locations # You'd do this using the calls within your points function balls - matrix(c(0,50,25,-150,-100,-50), ncol=2, byrow=F) # Draw a line from the origin to each ball location apply(balls, 1, function(x) lines(c(125, x[1]), c(-210, x[2]), col='red')) A more

Re: [R] enable object name to be called as object (a dataset)

2007-09-08 Thread Jim Price
a - 1:3 b - 11:13 c - 21:23 names - c('a','b','c') do.call(data.frame, list(sapply(names, function(x) get(x runner wrote: What I am trying to do is as follows: - I have listed names of all wanted objects (datasets A,B,C... ) in current workspace as a vector: obj -

Re: [R] Month end calculations

2007-08-30 Thread Jim Price
A simple example (avoiding using dates, just to show the principle) - this assumes that your data are already sorted (?order). temp - data.frame(subject = rep(1:2, each = 5), response = 1:10) print(temp) last - do.call(rbind, by(temp, temp$subject, function(x) tail(x, 1))) print(last) By

Re: [R] summarizing dataframe at variable/factor levels

2007-07-05 Thread Jim Price
my.data - data.frame( trts - rep(c('Drug 1','Drug2'), each = 10), doses - rep(c('Low dose','High dose'), 10), resp - rnorm(20) ) tapply(my.data$resp, list(my.data$trts, my.data$doses), mean) Jim Afshartous, David wrote: All, Is there an efficient way to

[R] Changing graphics height when using grid and lattice

2007-06-28 Thread Jim Price
Hi, I have recently been playing with the grid package in an attempt to create some pages containing multiple lattice plots on the same page. However, when I specify a grid layout with different widths, such as: pushViewport(viewport(layout = grid.layout(1, 2, unit(c(2, 1), null the