Re: [R] [Rd] How do I modify an exported function in a locked environment?

2006-07-20 Thread Gabor Grothendieck
As others have mentioned its not really a good idea to modify the namespace of a package and writing a wrapper as Duncan suggested is much preferable. An intermediate approach that is not as good as the wrapper but better than modifying the namespace is to copy the objects of interest to your

Re: [R] Reading data with blank elements

2006-07-21 Thread Gabor Grothendieck
See if this works: read.csv(datafile.csv, row.names = 1, fill = TRUE) On 7/21/06, Ahamarshan jn [EMAIL PROTECTED] wrote: Hi, I have a dataset saved in *.csv format, that contains 13 columns (the first column being the title name and the rest experiments) and about 2500 rows. Not all

Re: [R] intersect of list elements

2006-07-21 Thread Gabor Grothendieck
The following assumes that within each component of vectorlist the vector elements are unique. In that case the first two lines define vectorlist and perform the grep, as in your post. Elements of the intersection must occur n times where n is the number of components of vectorlist that match the

Re: [R] (no subject)

2006-07-22 Thread Gabor Grothendieck
Check out this recent thread: https://www.stat.math.ethz.ch/pipermail/r-help/2006-July/109731.html On 7/22/06, ahmed el kenawy [EMAIL PROTECTED] wrote: hi i created two files in excel with a dbf format in a similar way. the first is opened in R, however, when i try to open the second. i

Re: [R] multcomp plotting Please help :)

2006-07-22 Thread Gabor Grothendieck
On 7/22/06, Nair, Murlidharan T [EMAIL PROTECTED] wrote: I REALLY NEED HELP WITH THIS PLEASE [] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] Multcomp

2006-07-22 Thread Gabor Grothendieck
On 7/22/06, Nair, Murlidharan T [EMAIL PROTECTED] wrote: Here it is again, hope this is more clear I am using the following data (only a small subset is given): Habitat Fungus.yield Birch 20.83829053 Birch 22.9718181 Birch 22.28216829 Birch 24.23136797 Birch 22.32147961 Birch

Re: [R] Multcomp

2006-07-22 Thread Gabor Grothendieck
On 7/22/06, Nair, Murlidharan T [EMAIL PROTECTED] wrote: -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Saturday, July 22, 2006 1:37 PM To: Nair, Murlidharan T Cc: R-help@stat.math.ethz.ch Subject: Re: [R] Multcomp On 7/22/06, Nair, Murlidharan T [EMAIL

Re: [R] RfW 2.3.1: regular expressions to detect pairs of identical word-final character sequences

2006-07-22 Thread Gabor Grothendieck
The following requires more than just a single gsub but it does solve the problem. Modify to suit. The first gsub places ... around the first occurrence of any duplicated suffixes. We use the (?=...) zero width regexp to circumvent the nesting problem. Then we use strapply from the gsubfn

Re: [R] diff, POSIXct, POSIXlt, POSIXt

2006-07-23 Thread Gabor Grothendieck
Moving this to r-devel. Looking at the diff.POSIXt code we see the problem is that it takes the length of the input using length which is wrong since in the case of POSIXlt the length is always 9 (or maybe length should be defined differently for POSIXlt?). Try this which gives the same problem:

Re: [R] Is there anywhere recycle()?

2006-07-23 Thread Gabor Grothendieck
Try: foo2 - function(x, a) cbind(x,a)[,2] On 7/23/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Hello! I am writting a function, which should recycle one of its arguments if length of the argument is approprate i.e. something like foo - function(x, a) { n - length(x) if(length(a) n) {

Re: [R] Is there anywhere recycle()?

2006-07-23 Thread Gabor Grothendieck
Here is another possibility: rep(a, length = length(x)) On 7/23/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Hi, Gabor Grothendieck wrote: Try: foo2 - function(x, a) cbind(x,a)[,2] thank you for this. It does work to some extent, but not much better than mine foo. foo2(c(1, 2, 3

Re: [R] Saving R objects

2006-07-23 Thread Gabor Grothendieck
It depends on what information you want to save and how the program on the other end needs it. For the save version I would at least use ascii = TRUE to get it in a more readable fashion. Look at file.show(mult_test.dat) file.show(mult.out) # but use ascii=TRUE on your save statement. to see

Re: [R] diff, POSIXct, POSIXlt, POSIXt

2006-07-23 Thread Gabor Grothendieck
Just one more comment. It is possible to define length.POSIXlt yourself in which case diff works with POSIXlt objects. length.POSIXlt - function(x) length(x[[1]]) diff(dts) Time differences of 91, 92, 183, 91, 92, 182, 91, 92, 182 days On 7/23/06, Gabor Grothendieck [EMAIL PROTECTED

Re: [R] Correlations by group

2006-07-24 Thread Gabor Grothendieck
On 7/24/06, Peter J. Lee [EMAIL PROTECTED] wrote: I'm aware that S N Krishna asked the same question. However, I have failed to implement the posted solution for running rank order correlations on multiple subsets of data using the by() function. Here is my problem: Take a set of data from

Re: [R] trim function in R

2006-07-24 Thread Gabor Grothendieck
A . (dot) matches any character and $ matches the end of string so this replaces the last two characters with the empty string: sub(..$, , x) On 7/24/06, Wade Wall [EMAIL PROTECTED] wrote: Hi all, I am looking for a function in R to trim the last two characters of an 8 character string in

Re: [R] Identifying peaks (or offsets) in a time series

2006-07-24 Thread Gabor Grothendieck
Try: RSiteSearch(finding peaks) On 7/24/06, Tauber, Dr E. [EMAIL PROTECTED] wrote: Dear R-users, We are monitoring the activity of animals during a few days period. The data from each animal (crossing of infra-red beam) are collected as a time series (in 30 min bins). An example is

Re: [R] Saving R objects

2006-07-24 Thread Gabor Grothendieck
,estimate,lower,upper,p.val.raw,p.val.bon,p.val.adj) write.table(out.data.mat, file=filename.csv, sep=,, qmethod=double, col.name=NA) Thanks ../Murli From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Sun 7/23/2006 10:11 PM To: Nair, Murlidharan T Cc: r

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-24 Thread Gabor Grothendieck
Try: matplot(levels(data$Quarter), matrix(data$Consumption, 4), type = o) On 7/24/06, John McHenry [EMAIL PROTECTED] wrote: Hi WizaRds, I'd like to overplot UK fuel consumption per quarter over the course of five years. Sounds simple enough? Unless I'm missing something, the following

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-24 Thread Gabor Grothendieck
And if lattice is ok then try this: library(lattice) xyplot(Consumption ~ Quarter, group = Year, data, type = o) On 7/24/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try: matplot(levels(data$Quarter), matrix(data$Consumption, 4), type = o) On 7/24/06, John McHenry [EMAIL PROTECTED

Re: [R] RfW 2.3.1: regular expressions to detect pairs of identical word-final character sequences

2006-07-25 Thread Gabor Grothendieck
Regarding having to do a lot of backtracking one can just look at the relative comparison of speeds and we see that they are comparable in speed. In fact the bottleneck is not the backtacking but strapply. I had coded the regexp version for compactness of code but if we replace the strapply with

Re: [R] greek letters, text, and values in labels

2006-07-25 Thread Gabor Grothendieck
Try: plot(1:10, main = bquote(Results for ~ theta == .(theta))) On 7/25/06, Adrian Dragulescu [EMAIL PROTECTED] wrote: Hello, I want to have a title that will look something like: Results for \theta=2.1, given that I have a variable theta=2.1, and \theta should show on the screen like

Re: [R] RfW 2.3.1: regular expressions to detect pairs of identical word-final character sequences

2006-07-25 Thread Gabor Grothendieck
\\1, out, perl = TRUE)) On 7/23/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: The following requires more than just a single gsub but it does solve the problem. Modify to suit. The first gsub places ... around the first occurrence of any duplicated suffixes. We use the (?=...) zero width

Re: [R] generating sequences with gaps

2006-07-25 Thread Gabor Grothendieck
Here are a few possibilies: x - c(4, 12, 20) rep(x, each = 3) + 0:2 rep(x, each = 3) + sequence(rep(3, length(x))) - 1 c(sapply(x, seq, length = 3)) On 7/25/06, etienne [EMAIL PROTECTED] wrote: I need sequences that have gaps in them, such as the following: 4 5 6 | 12 13 14 | 20 21 22

Re: [R] Main title of plot

2006-07-26 Thread Gabor Grothendieck
This was just discussed yesterday. See the thread: https://www.stat.math.ethz.ch/pipermail/r-help/2006-July/109931.html On 7/26/06, Marco Boks [EMAIL PROTECTED] wrote: I am a newbie, and I am afraid this may be a rather trivial question. However I could not find the answer anywhere. I am

Re: [R] the first and last case

2006-07-26 Thread Gabor Grothendieck
Try these: # 1 library(Hmisc) summary(y ~ ind, dat, fun = range, overall = FALSE) # 2 # or with specified column names f - function(x) c(head = head(x,1), tail = tail(x,1)) summary(y ~ ind, dat, fun = f, overall = FALSE) # 3 # another approach using by - same f as above do.call(rbind, by(dat$y,

Re: [R] Moving Average

2006-07-26 Thread Gabor Grothendieck
See ?filter - simple and exponential are special cases ?runmean - in package caTools (the fastest) ?rollmean - in zoo package ?embed - can write your own using embed as basis ?sma - in package fSeries, also see ewma in same package Probably other functions in other packages too. On 7/26/06,

Re: [R] Branching on 'grep' returns...

2006-07-26 Thread Gabor Grothendieck
If you are using grep then I think you have it right. Note that this %in% trg is also available. On 26 Jul 2006 11:16:25 -0400, Allen S. Rout [EMAIL PROTECTED] wrote: Greetings, all. I'm fiddling with some text manipulation in R, and I've found something which feels counterintuitive

Re: [R] Multcomp

2006-07-26 Thread Gabor Grothendieck
Look through multcomp:::plot.hmtest to find out which components of an hmtest object are actually used. Now look at what an hmtest object looks like by doing this dput(Dcirec) or looking through the source of the function that produces hmtest objects. With this information in hand we can

Re: [R] Multcomp

2006-07-26 Thread Gabor Grothendieck
Here is a minor simplication: my.hmtest - structure(list( estimate = t(t(out.data.mat[,estimate,drop=FALSE])), conf.int = out.data.mat[,2:3], ctype = Dunnett), class = hmtest) plot(my.hmtest) On 7/26/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Look through multcomp

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-26 Thread Gabor Grothendieck
With the lattice package it would be done like this (where the panel.points function places large red pluses on the plot): xyplot(Consumption ~ Quarter, group = Year, data, type = o) trellis.focus(panel, 1, 1) panel.points(1:4, mean.per.quarter, pch = +, cex = 2, col = red) trellis.unfocus() On

Re: [R] How to get the name of the first argument in an assignment function?

2006-07-27 Thread Gabor Grothendieck
If you are willing to write fu2[Var] - 3 instead of fu2(Var) - 3 then this workaround may suffice: fu2 - structure(NA, class = fu2) [-.fu2 - function(x, ..., value) { print(match.call()[[3]]); fu2 } # test fu2[Var] - 3 # prints Var On 7/27/06, Heinz Tuechler [EMAIL PROTECTED] wrote: Dear

Re: [R] how to resample (or resize) matrix?

2006-07-27 Thread Gabor Grothendieck
Assuming the problem is to partition the 10x10 matrix x into 25 two by two squares and then average each of those squares, try this: apply(array(x, c(2,5,2,5)), c(2,4), mean) On 7/27/06, Vladimir Eremeev [EMAIL PROTECTED] wrote: Dear r-help, I have a matrix, suppose, 10x10, and I need the

Re: [R] deparse(substitute(foo))

2006-07-27 Thread Gabor Grothendieck
See ?match.call On 7/27/06, Armstrong, Whit [EMAIL PROTECTED] wrote: I see that plot.default uses deparse(substitute(x)) to extract the character name of an argument and put it on the vertical axis. Hence: foo - 1:10 plot( foo ) will put the label foo on the vertical axis. However, for

Re: [R] How to get the name of the first argument in an assignment function?

2006-07-27 Thread Gabor Grothendieck
The complexity of the function should not matter. Here is another example of this technique: http://tolstoy.newcastle.edu.au/R/help/04/06/1430.html On 7/27/06, Heinz Tuechler [EMAIL PROTECTED] wrote: At 06:10 27.07.2006 -0400, Gabor Grothendieck wrote: If you are willing to write fu2[Var] - 3

Re: [R] inserting rows into a matrix

2006-07-27 Thread Gabor Grothendieck
Try this where f and A2 are as in your post: out -f(A2[A20]) replace(matrix(0, length(A2), ncol(out)), A2 0, out) On 7/27/06, Robin Hankin [EMAIL PROTECTED] wrote: Hi I have a little vector function that takes a vector A of strictly positive integers and outputs a matrix M each of

Re: [R] Vector extracted from a matrix. How can I specify dimensions in as.matrix?

2006-07-27 Thread Gabor Grothendieck
Use the notation x[ , 1, drop = FALSE] See ?[ On 7/27/06, Neuro LeSuperHéros [EMAIL PROTECTED] wrote: Transpose vector extracted from a matrix Hello, I am doing a recursive analysis that uses every line (vector) of a matrix in a loop. In the model, I need to transpose those vectors that are

Re: [R] greek letters, text, and values in labels

2006-07-27 Thread Gabor Grothendieck
Try this where gr and theta are as in your post: xyplot(1~1|gr, main = as.expression(bquote(theta == .(theta))), strip = strip.custom(factor.levels = expression(theta, beta)) ) On 7/27/06, Valentin Todorov [EMAIL PROTECTED] wrote: Unfortunately this does not work for lattice

Re: [R] Moving from Splus to R - advice/opinions request from a management perspective

2006-07-27 Thread Gabor Grothendieck
How large is your data? If its large you may or may not have problems. If its small you probably won't. Try prototyping the most data intensive portion in R before you commit significant resources. S Plus can time stamp objects and R cannot although you could come up with some workarounds for

Re: [R] how to skip certain rows when reading data

2006-07-27 Thread Gabor Grothendieck
Just read them in and throw them away: read.table(myfile.dat, ...whatever...)[-c(10, 12), ] On 7/27/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear all, I am reading the data using read.table. However, there are a few rows I want to skip. How can I do that in an easy way? Suppose I

Re: [R] Non-interpreted strings

2006-07-28 Thread Gabor Grothendieck
Enter this at the console x - scan(what = ) and after pressing the enter after the right paren, do a paste and then press enter twice. On 7/27/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am new to R, so please forgive me if there is an obvious answer to this question. I have done

Re: [R] Non-interpreted strings

2006-07-28 Thread Gabor Grothendieck
Or even easier, x - scan(clipboard, what = ) at least on Windows. On 7/28/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Enter this at the console x - scan(what = ) and after pressing the enter after the right paren, do a paste and then press enter twice. On 7/27/06, [EMAIL

[R] placing rectangle behind plot

2006-07-29 Thread Gabor Grothendieck
I am trying to create a lattice plot and would like to later, i.e. after the plot is drawn, add a grey rectangle behind a portion of it. The following works except that the rectrangle is on top of and obscures a portion of the chart. I also tried adding col = transparent to the gpar list but that

Re: [R] placing rectangle behind plot

2006-07-29 Thread Gabor Grothendieck
The reason I explicitly specified in the problem that the rectangle should not be drawn first is that the xyplot is issued as part of a larger routine that I don't want to modify. On 7/29/06, Sebastian P. Luque [EMAIL PROTECTED] wrote: Hi Gabor, On Sat, 29 Jul 2006 17:20:29 -0400, Gabor

Re: [R] overlaying the values of tab-delim file in to a pre-existing matrix

2006-07-30 Thread Gabor Grothendieck
Please provide reproducible examples (as discussed at end of each posting): Lines - Apple S 21.0 Apple A 21.6 Apple O 43.0 Orange A 45.0 Orange O 64.0 Orange S 32.5 Mango M 40.3 Mango A 32.6 Mango S 24.6 tb - read.table(textConnection(Lines)) # alternative 1 - create a matrix tmat

Re: [R] main= bquote(paste(Results for , beta, 3, ==.(b1)))) doesn't work.

2006-07-30 Thread Gabor Grothendieck
I assume the 3 is supposed to be a subscript. Try this: b1 - x - y - 1 plot(x,y, main = bquote(Results for ~ beta[3] ==.(b1))) On 7/30/06, Marco Boks [EMAIL PROTECTED] wrote: Hi, I need to plot the beta as the symbol, followed by the index 3 as the title of a graph. This code works

Re: [R] placing rectangle behind plot

2006-07-30 Thread Gabor Grothendieck
lines afterwards or other lines, rectangles, etc. On 7/30/06, Paul Murrell [EMAIL PROTECTED] wrote: Hi Gabor Grothendieck wrote: I am trying to create a lattice plot and would like to later, i.e. after the plot is drawn, add a grey rectangle behind a portion of it. The following works

Re: [R] question about dataframe (sensory) in PLS package

2006-07-30 Thread Gabor Grothendieck
Try: ?sensory str(sensory) dput(sensory) lapply(sensory, class) lapply(sensory, dim) to see what it looks like inside. Seems that sensory is a data frame consisting of two columns each of which is a matrix except that each has a class of AsIs. Thus try this (where I(...) creates objects of

Re: [R] placing rectangle behind plot

2006-07-30 Thread Gabor Grothendieck
-plot panel over rectangle do.call(panel.xyplot, trellis.panelArgs()) trellis.unfocus() nevertheless, as a point of general interest I would still be interested to know what a general grid-based solution might be. On 7/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Thanks. That's helpful

Re: [R] How does biplot.princomp scale its axes?

2006-07-31 Thread Gabor Grothendieck
Its easiest to just check the source. biplot is a generic which calls biplot.princomp which calls biplot.default which in turn calls plot so try this and examine the source: stats:::biplot.default On 7/31/06, Patrick Connolly [EMAIL PROTECTED] wrote: I'm attempting to modify how biplot draws

Re: [R] Global setting for na.rm=TRUE

2006-08-01 Thread Gabor Grothendieck
There is a global option setting for na.action. See ?na.action . That does not completely address your question but might help with lm, glm, etc. You could define your own wrapper functions if you know ahead of time which functions with na.rm= args you need. e.g. my.max = function(..., na.rm =

Re: [R] Fitting models in a loop

2006-08-01 Thread Gabor Grothendieck
A simple way around this is to pass it as a data frame. In the code below the only change we made was to change the formula from y ~ poly(x, i) to y ~ . and pass poly(x,i) in a data frame as argument 2 of lm: # test data set.seed(1) x - 1:10 y - x^3 + rnorm(10) # run same code except change the

Re: [R] Fitting models in a loop

2006-08-01 Thread Gabor Grothendieck
Actually in thinking about this some more that still gets you into a mess if you want to do prediction at anything other than the original points. On 8/1/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: A simple way around this is to pass it as a data frame. In the code below the only change we

Re: [R] Fitting models in a loop

2006-08-01 Thread Gabor Grothendieck
in 1:3) print(environment(formula(mod[[j]]))$i) # following two lines give same answer # showing prediction works predict(mod[[2]], list(x = 1:10)) fitted(lm(y ~ poly(x,2))) On 8/1/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Actually in thinking about this some more that still gets you

Re: [R] open DLL in R

2006-08-01 Thread Gabor Grothendieck
This refers to the windows command pedump.exe found in the Rtools collection at: http://www.murdoch-sutherland.com/Rtools/ On 8/2/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello Sir, I am just wondering that pedump is a command of 'R' because in could not find in the 'R' help using

Re: [R] loop, pipe connection, quote/unquote

2006-08-02 Thread Gabor Grothendieck
Try something along these lines assuming that the current directory is \Program Files\R\R-2.3.1pat. Note use of paste to create the command line to pass to pipe: # search for indicated string in each of the files and # for each match output the file name Files - c(CHANGES, COPYING, NEWS, NEWS)

Re: [R] How to share variables

2006-08-02 Thread Gabor Grothendieck
On 8/2/06, Sergio Martino [EMAIL PROTECTED] wrote: Hi, I would like to realize in R a structure like the fortran common ie a way to declare some variable that can only be accessed by all the functions which need to. Browsing the archive it seems that the simplest way is to declare the

Re: [R] ordering columns (longitudinal data in wide format)

2006-08-02 Thread Gabor Grothendieck
Assuming this data: s - structure(list(L.qol.0 = 83, L.qol.0.08 = 86, L.qol.0.17 = 89, L.qol.0.25 = 92, L.qol.0.5 = 91, L.qol.0.42 = 87, L.qol.0.34 = 90), .Names = c(L.qol.0, L.qol.0.08, L.qol.0.17, L.qol.0.25, L.qol.0.5, L.qol.0.42, L.qol.0.34), class = data.frame, row.names = 1) #

Re: [R] help with formatting legend in xyplot

2006-08-02 Thread Gabor Grothendieck
If you set it through par.settings then it will affect both the drawing and the legend: xyplot(Sepal.Length ~ Petal.Length, iris, groups = Species, auto.key = TRUE, par.settings = list(superpose.symbol = list(pch = *, cex = 1))) On 8/2/06, Kaushik Katari [EMAIL PROTECTED] wrote: I am doing a

Re: [R] ggplot facet label font size

2006-08-02 Thread Gabor Grothendieck
On 8/2/06, Walker, Sam [EMAIL PROTECTED] wrote: How do I change the font size in the facet labels along the edges of the plot? For example (from the ggplot help file): p-ggplot(tips, sex ~ smoker, aesthetics=list(x=tip/total_bill)) gghistogram(p) In this plot, the facet labels are

Re: [R] Finding the position of a variable in a data.frame

2006-08-03 Thread Gabor Grothendieck
On 8/3/06, John Kane [EMAIL PROTECTED] wrote: --- Don MacQueen [EMAIL PROTECTED] wrote: You don't need to find out the column index. This works: Df[5,'bat'] - 100 -Don Thanks, I'd tried Df[5, bat] - 100 :( I never thought of the ' ' being needed. Right -- the quotes are

Re: [R] ggplot facet label font size

2006-08-03 Thread Gabor Grothendieck
, in this case 2 (sex+smoker). Thanks in advance... -Sam -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 02, 2006 6:04 PM To: Walker, Sam Cc: r-help@stat.math.ethz.ch Subject: Re: [R] ggplot facet label font size On 8/2/06, Walker, Sam

Re: [R] ggplot facet label font size

2006-08-03 Thread Gabor Grothendieck
Just sending this to you. One thing that might be easy to do yet give a lot of flexibility is to: 1. put meaningful names on the grobs. Even with just this it would be possible to do a getNames() in grid and then from inspection grid.edit the appropriate one(s). 2. create a routine that

Re: [R] Data frame referencing?

2006-08-04 Thread Gabor Grothendieck
When specifying a column name with [ the name must be quoted (unlike when using it with $): a[a$y 0.5, y] - 1 On 8/4/06, Sander Oom [EMAIL PROTECTED] wrote: Dear R users, When you do: x - rnorm(10) y - rnorm(10) z - rnorm(10) a - data.frame(x,y,z) a$x [1] 1.37821893

Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Gabor Grothendieck
Use atop: plot(1, main = expression(atop( ^14*C*-glyphosate line, line2))) On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it

Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Gabor Grothendieck
Sorry, you wanted a ylab=, not a main=. Try using xyplot in lattice: library(lattice) xyplot(1~1, ylab = expression(atop(phantom(0)^14*C*-glyphosate line, line2))) On 8/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Use atop: plot(1, main = expression(atop( ^14*C*-glyphosate line

Re: [R] ggplot facet label font size

2006-08-04 Thread Gabor Grothendieck
(grid.get(pretty)) On 8/3/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: If you are willing to use grid then you could create only the sex factor in the left strips since its already in the desired position but when displaying it output a factor.level, i.e. label of A. (my.strip.left

Re: [R] formating for dist function

2006-08-05 Thread Gabor Grothendieck
Here are three ways: # read in data Lines - object1 object1 78 object1 object2 45 object1 object3 34 object1 object4 45 object2 object2 89 object2 object3 32 object2 object4 13 DF - read.table(textConnection(Lines)) # 1 - xtabs xt - as.matrix(xtabs(V3 ~., DF)) # 2 - reshape wide - reshape(DF,

Re: [R] ordering by a datframe date

2006-08-05 Thread Gabor Grothendieck
Try this: Lines - story,datepub story10,1 April 1999 story 90,1 March 2002 story 37,10 July 1985 DF - read.csv(textConnection(Lines)) DF[order(as.Date(DF$datepub, %d %B %Y)),] On 8/6/06, Bob Green [EMAIL PROTECTED] wrote: I am hoping for some advice regarding ordering a dataframe, by date.

Re: [R] classification tables

2006-08-07 Thread Gabor Grothendieck
Also check out CrossTable in the gmodels package. Regarding your other question, assuming we have tab-table(x,y) as in Philippe's post, the fraction of pairs in x and y that match can be calculated via any of these: sum(x==y) / length(x) sum(diag(tab)) / sum(tab) library(e1071)

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Gabor Grothendieck
There are many clustering functions in R and R packages and some take distance objects whereas others do not. You likely read about hclust or some different clustering function. See ?kmeans for the kmeans function and also look at the CRAN Task View on clustering for other clustering functions:

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Gabor Grothendieck
: Functionkmeans() from package stats provides several algorithms for computing partitions with respect to Euclidean distance. Hence why I am using a euclidean distance matrix. Why is this incorrect? Gabor Grothendieck [EMAIL

Re: [R] Plots

2006-08-07 Thread Gabor Grothendieck
Try: RSiteSearch(Horses and Hounds) On 8/7/06, Sonal Darbari [EMAIL PROTECTED] wrote: Hi, What commands are needed to get an output like this: 1. On X-Axis : 2 Indices ex. SP500 and DOW JONES 2. Their repective dates If I use the plot command, I get one output if I use it again, I

Re: [R] Plots

2006-08-07 Thread Gabor Grothendieck
Also RSiteSearch(ts.plot.2Axis) On 8/7/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try: RSiteSearch(Horses and Hounds) On 8/7/06, Sonal Darbari [EMAIL PROTECTED] wrote: Hi, What commands are needed to get an output like this: 1. On X-Axis : 2 Indices ex. SP500 and DOW

Re: [R] Retain only those records from a dataframe that exist in another dataframe

2006-08-07 Thread Gabor Grothendieck
Although this is probably not directly applicable to this problem I might mention here that merge.zoo does support left and right joins and that handles problems similar to this. z3t, z3ft, z3tf and z3f below have times of both unioned, the times of z2, the times of z1 and the times of both z1

Re: [R] Pairwise n for large correlation tables?

2006-08-07 Thread Gabor Grothendieck
Try this: # mat is test matrix mat - matrix(1:25, 5) mat[2,2] - mat[3,4] - NA crossprod(!is.na(mat)) On 8/7/06, Adam D. I. Kramer [EMAIL PROTECTED] wrote: Hello, I'm using a very large data set (n 100,000 for 7 columns), for which I'm pretty happy dealing with pairwise-deleted correlations

Re: [R] Netiquette, was Re: ... gfortran and gcc...

2006-08-08 Thread Gabor Grothendieck
I agree. Also, sending a copy to the poster means that they are likely to get it first which seems like a desirable courtesy. On 8/8/06, Marc Schwartz (via MN) [EMAIL PROTECTED] wrote: [Re-sending to the list only for archiving, as my original reply had too many recipients and I cancelled it.]

Re: [R] legend on trellis plot

2006-08-09 Thread Gabor Grothendieck
1. Use the x, y and corner components to the key= list to specify the legend position, and 2. pass the panel.number in the panel function and test that as shown in the panel function below. Alternately you can place the horizontal line on afterwards using

Re: [R] evolutionary computing in R

2006-08-09 Thread Gabor Grothendieck
Check out the machining learning task view at: http://cran.r-project.org/src/contrib/Views/ On 8/9/06, Christian Miehle [EMAIL PROTECTED] wrote: Hallo, Ich bin auf der Suche nach umgesetzten evolutionären Algorithmen in R. Leider habe ich kein entsprechendes Package oder Funktionen dieser

Re: [R] data.frame to shape

2006-08-09 Thread Gabor Grothendieck
Try this: DF[unlist(tapply(rownames(DF), DF$id, function(x) c(x, x[1]))),] On 8/9/06, Leonardo Lami [EMAIL PROTECTED] wrote: Hi all, I have a simple question: I have a data.frame like this: id x y 1 50 1647685 4815259 2 50 1647546 4815196 3 50 1647454 4815294 4 50

Re: [R] objects and environments

2006-08-09 Thread Gabor Grothendieck
Dmitris has already provided the solution but just throught I would' mention that your third alternative can be written: apply(mymatrix, 1, fun2, bb = bb) (assuming fun2 has arguments idx and bb) which is not nearly so ugly so you might reconsider whether its ok for you to just pass bb. On

Re: [R] index.cond in xyplot

2006-08-09 Thread Gabor Grothendieck
That's not a valid specification. See the description of the index.cond argument in ?xyplot and in particular this part: If 'index.cond' is a list, it has to be as long as the number of conditioning variables, and the 'i'-th component has to be a valid

Re: [R] Is there a better way than x[1:length(x)-1] ?

2006-08-10 Thread Gabor Grothendieck
On 8/9/06, John McHenry [EMAIL PROTECTED] wrote: Hi WizaRds, In MATLAB you can do x=1:10 and then specify x(2:end) to get 2 3 4 5 6 7 8 9 10 In R you could do the above via: x[-1] or whatever (note that in MATLAB the parenthetic index notation is used, not brackets as in R).

Re: [R] Geometrical Interpretation of Eigen value and Eigen vector

2006-08-10 Thread Gabor Grothendieck
A matrix M can be thought of as a linear transformation which maps input vector x to output vector y: y = Mx The eigenvectors are those directions that this mapping preserves. That is if x is an eigenvector then y = ax for some scalar a. i.e. y lies in the same one dimensional space as x.

Re: [R] basic question re lm()

2006-08-10 Thread Gabor Grothendieck
Try: lm(Sepal.Length ~., iris) On 8/10/06, r user [EMAIL PROTECTED] wrote: I am using R in a Windows environment. I have a basic question regarding lm(). I have a dataframe data1 with ncol=w. I know that my dependent variable is in column1. Is there a way to write the regression formula

Re: [R] day, month, year functions

2006-08-10 Thread Gabor Grothendieck
Here are three ways: xx - as.Date(2006-01-05) # 1. use as.POSIXlt as.POSIXlt(xx)$mday as.POSIXlt(xx)$mon + 1 as.POSIXlt(xx)$year + 1900 # 2. use format as.numeric(format(xx, %d)) as.numeric(format(xx, %m)) as.numeric(format(xx, %Y)) # 3. use month.day.year in chron package library(chron)

Re: [R] Multiple density curves

2006-08-11 Thread Gabor Grothendieck
From your description I assume you want both histograms and the densities all on the same chart. With existing R graphics I am not sure that there really is a simple way to do that. That aside, note that the hist function returns a list of components that includes - breaks, defining the

Re: [R] Multiple density curves

2006-08-11 Thread Gabor Grothendieck
, breaks = breaks, freq = FALSE, density = 10) lines(density(DF$A2), col = blue) On 8/11/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: From your description I assume you want both histograms and the densities all on the same chart. With existing R graphics I am not sure

Re: [R] Multiple density curves

2006-08-11 Thread Gabor Grothendieck
[,j], border = j, lwd = j, lty = j, breaks = breaks, col = transparent, ...) panel.densityplot(DF[,j], col = j, ...) }) On 8/11/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: The code below was missing the breaks= argument to hist. I had not noticed because

Re: [R] An apply and rep question

2006-08-11 Thread Gabor Grothendieck
The approach here is to perform the repetition on the indices (or rownames) rather than on the data frame directly. Using the builtin data frame BOD any of the following would work: BOD[gl(nrow(BOD), 2),] BOD[rep(1:nrow(BOD), each = 2),] BOD[rep(rownames(BOD), each = 2),] On 8/11/06, Horace Tso

Re: [R] x tick labels - sparse?

2006-08-11 Thread Gabor Grothendieck
Try this: x - seq(-100,1000,25) y - x * x plot(x, y, xaxt = n) axis(1, x[x %% 100 == 0]) On 8/11/06, Darren Weber [EMAIL PROTECTED] wrote: Hi, I'm stuck on creating a plot with x tick labels for every Nth tick mark - how is that done? I don't see a simple solution to this in help(plot)

Re: [R] adding multiple fitted curves to xyplot graph

2006-08-16 Thread Gabor Grothendieck
Try this after displaying the xyplot: # this fit.curve returns the whole nls object, not the coefs fit.curve-function(tab) { nls(y1 ~ 100/(1+exp(((-log(81))/a)*(x1-b))),

Re: [R] bwplot in loop doesn't produce any output

2006-08-16 Thread Gabor Grothendieck
Its a FAQ http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f On 8/16/06, Nick Desilsky [EMAIL PROTECTED] wrote: Hi, running the following code by itself runs as expected.

Re: [R] separate row averages for different parts of an array

2006-08-17 Thread Gabor Grothendieck
The following reshapes mat so we can take the means of the columns of the resulting 3d array and then transposes it back to the original orientation: t(colMeans(array(t(mat), c(100, 448, 24 You might want to try it on this test set first where anscombe is an 11x8 data set built into R.

Re: [R] Plots Without Displaying

2006-08-17 Thread Gabor Grothendieck
Also check out the displaylist: http://tolstoy.newcastle.edu.au/R/help/04/05/0817.html On 8/17/06, Lothar Botelho-Machado [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thank you, It seems that a list of plots is just possible using lattice plots. But that's a good

Re: [R] rbind-ing vectors inside lists

2006-08-17 Thread Gabor Grothendieck
Try: mapply(rbind, a, b, SIMPLIFY = FALSE) On 8/17/06, Domenico Vistocco [EMAIL PROTECTED] wrote: Dear helpeRs, suppose I have two lists as follows: a = list(1:5,5:9) b = lapply(a,*,2) I would like to rbind-ing the two lists, that is I would like to use something as rbind applied

Re: [R] day, month, year functions

2006-08-17 Thread Gabor Grothendieck
On 8/17/06, Martin Maechler [EMAIL PROTECTED] wrote: Gregor == Gregor Gorjanc [EMAIL PROTECTED] on Fri, 11 Aug 2006 00:27:27 + (UTC) writes: Gregor Gabor Grothendieck ggrothendieck at gmail.com writes: Here are three ways: xx - as.Date(2006-01-05) # 1

Re: [R] getting sapply to skip columns with non-numeric data?

2006-08-17 Thread Gabor Grothendieck
Use the first few rows of iris as test data and try this where isnum is 1 for each numeric column and NA for others. irish - head(iris) isnum - ifelse(sapply(iris, class) == numeric, 1, NA) iris.data - data.matrix(iris) rbind(iris, colMeans(iris.data) * isnum, sd(iris.data) * isnum) On 8/17/06,

Re: [R] Lattice package par.settings/trellis.par.settings questions

2006-08-17 Thread Gabor Grothendieck
The parameter names are axis.text$font and axis.text$cex . Try issuing the command: trellis.par.get() to get a complete list. Here is an example: histogram(1:10, par.settings = list(axis.text = list(font = 2, cex = 0.5))) On 8/17/06, Debarchana Ghosh [EMAIL PROTECTED] wrote: Hi All, I'm

Re: [R] Insert rows - how can I accomplish this in R

2006-08-18 Thread Gabor Grothendieck
Here are two solutions. In both we break up DF into rows which start with 1. In solution #1 we create a new data frame with the required sequence for A and zeros for B and then we fill it in. In solution #2 we convert each set of rows to a zoo object z where column A is the times and B is the

Re: [R] Insert rows - how can I accomplish this in R

2006-08-18 Thread Gabor Grothendieck
(rbind, by(DF, cumsum(DF$A == 1), f)) Error in zoo(, time(as.ts(z)), z, fill = 0) : unused argument(s) (fill ...) Unable to figure out the cause. Thanks, Sachin Gabor Grothendieck [EMAIL PROTECTED] wrote: Here are two solutions. In both we break up DF into rows which start with 1

<    1   2   3   4   5   6   7   8   9   10   >