Re: [R] sapply, lattice functions

2010-03-20 Thread Sundar Dorai-Raj
You're right. It's necessary for xyplot though to prevent grouping. On Mar 20, 2010 10:43 AM, Dieter Menne dieter.me...@menne-biomed.de wrote: Sundar Dorai-Raj-2 wrote: Or perhaps more clearly, histogram(~a1 + b1 + c1, data = aa, o... Why outer=TRUE? Looks same for me without: Dieter

Re: [R] sapply, lattice functions

2010-03-19 Thread Sundar Dorai-Raj
Or perhaps more clearly, histogram(~a1 + b1 + c1, data = aa, outer = TRUE) --sundar On Fri, Mar 19, 2010 at 3:50 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: histogram(~ values | ind, stack(aa)) On Fri, Mar 19, 2010 at 5:44 PM, Santosh santosh2...@gmail.com wrote:

Re: [R] Source code for the t-distribution

2010-03-09 Thread Sundar Dorai-Raj
Here it is. https://svn.r-project.org/R/trunk/src/nmath/pt.c --sundar On Tue, Mar 9, 2010 at 4:24 AM, Ravi Kulkarni ravi.k...@gmail.com wrote: I have tried looking for the source code for the pt() function in https://svn.r-project.org/R/trunk/src/library/stats/ and am unable to find

Re: [R] capturing errors in Sweave

2010-03-02 Thread Sundar Dorai-Raj
Thanks, Berwin. That works just great! --sundar On Tue, Mar 2, 2010 at 12:57 AM, Berwin A Turlach ber...@maths.uwa.edu.auwrote: G'day Sundar, On Mon, 1 Mar 2010 23:46:55 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote: Thanks for the input, but I don't want try in the Sweave output. I

Re: [R] capturing errors in Sweave

2010-03-02 Thread Sundar Dorai-Raj
What I ended up using was: cat(unclass(tmp)) --sundar On Tue, Mar 2, 2010 at 8:58 AM, Berwin A Turlach ber...@maths.uwa.edu.auwrote: G'day Sundar, On Tue, 2 Mar 2010 01:03:54 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote: Thanks, Berwin. That works just great! You are welcome. I

[R] capturing errors in Sweave

2010-03-01 Thread Sundar Dorai-Raj
Hi, I'm writing a manual using Sweave and I want to be able to print errors from bad code. Here's an example: Function-4a= MySqrt - function(x) { if (missing(x)) { stop('x' is missing with no default) } if (!is.numeric(x)) { stop('x' should only be numeric) } if (x 0) {

Re: [R] capturing errors in Sweave

2010-03-01 Thread Sundar Dorai-Raj
Thanks for the input, but I don't want try in the Sweave output. I want the output to look just like it does in the console, as if an uncaptured error really did occur. --sundar On Mon, Mar 1, 2010 at 11:42 PM, Sharpie ch...@sharpsteen.net wrote: Sundar Dorai-Raj-2 wrote: Hi, I'm

Re: [R] How do I juxtapose two lattice graphs with common X axes such that the X axes line up?

2010-01-20 Thread Sundar Dorai-Raj
Try googling latticeExtra x.same for some examples. Here's one: http://www.mail-archive.com/r-help@r-project.org/msg39048.html On Wed, Jan 20, 2010 at 9:44 AM, George Chen glc...@stanford.edu wrote: Hello, I would like to juxtapose two lattice graphs with common X axes such that the X axes

Re: [R] Dynamic arguments in rbind function

2010-01-04 Thread Sundar Dorai-Raj
Use a list instead of assign then do.call(rbind, thelist). import.files - c(a.txt, b.txt, c.txt, d.txt, e.txt) imp - vector(list, length(import.files)) for (i in 1:length(import.files)) { imp[[i]] - read.delim(import.files[i], sep = , header = TRUE) } combined - do.call(rbind, imp) HTH,

Re: [R] makefile for sweave

2009-11-26 Thread Sundar Dorai-Raj
Is texi2dvi in your PATH? What happens if you open a CMD window and type texi2dvi at the prompt? --sundar On Thu, Nov 26, 2009 at 6:14 AM, Wolfgang Raffelsberger wr...@igbmc.fr wrote: Dear all, I can't get texi2dvi working right. Basically I'd like to convert a .lex to .pdf without having to

Re: [R] Why F value and Pr are not show in summary() of an aov() result?

2009-11-22 Thread Sundar Dorai-Raj
It's hard to read your code, so I won't comment on your specific example. So when all else fails read the documentation for ?summary.aov: They have columns ‘Df’, ‘Sum Sq’, ‘Mean Sq’, as well as ‘F value’ and ‘Pr(F)’ if there are non-zero residual degrees of freedom. So if you do

Re: [R] denoting max value in ylim

2009-11-20 Thread Sundar Dorai-Raj
ylim = c(0, max(log10(D10$Part.P))) Make sure you remove any 0s or NAs before computing the max though. --sundar On Fri, Nov 20, 2009 at 6:12 AM, helene frigstad helenefrigs...@hotmail.com wrote: Hi, is there any way to set the ylim range from zero to whatever is the max value in that

Re: [R] lapply() not converting columns to factors (no error message)

2009-11-16 Thread Sundar Dorai-Raj
Works for me: x - read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvcomp10.csv?tsid=20091116-075223-c3093ab0;)) names(x) x[2:13] - lapply(x[2:13], factor) levels(x$P1L55) [1] 0 1 is.factor(x$P1L96) [1] TRUE sessionInfo() R version 2.10.0 (2009-10-26)

Re: [R] lapply() not converting columns to factors (no error message)

2009-11-16 Thread Sundar Dorai-Raj
, because the same thing's worked for me too before but won't do now. I tried to reinstall it (base), but R says its there already which I expected it to be anyway. I don't quite know where the issue is. Very odd. --On 16 November 2009 04:59 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote

Re: [R] Trellis settings get lost when printing to pdf

2009-11-13 Thread Sundar Dorai-Raj
Did you make the changes before or after starting the device: library(lattice) ## before doesn't change the settings on the device: trellis.par.set(plot.symbol = list(col = red)) trellis.device(pdf, file = tmp.pdf) xyplot(1 ~ 1) dev.off() ## after does trellis.device(pdf, file = tmp.pdf)

Re: [R] tapply function

2009-11-03 Thread Sundar Dorai-Raj
you must have missing values in data. Try tapply(data, group, mean, na.rm = TRUE) If that's not the case, read the bottom of this email about the posting guide. HTH, --sundar On Tue, Nov 3, 2009 at 5:28 AM, FMH kagba2...@yahoo.com wrote: Hi, I tried to use tapply function to find the mean

Re: [R] Issue with %in% - not matching identical rows in data frames

2009-11-03 Thread Sundar Dorai-Raj
?%in% says x and table must be vectors. You supplied data.frames. So %in% is coercing your today.sequence to a vector using as.character(today.sequence) Perhaps you should paste the columns together first: x - do.call(paste, c(sequence, sep = ::)) table - do.call(paste, c(today.sequence, sep =

Re: [R] How can I run a function to a piece of text?

2009-10-16 Thread Sundar Dorai-Raj
Based solely on what you told us, this can be done using eval(parse(text=...)) cmd - sprintf(mean(%s), script) eval(parse(text = cmd)) However, with more context, there may be a better solution. See, for example, install.packages(fortunes) library(fortunes) fortune(parse()) HTH, --sundar On

Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread Sundar Dorai-Raj
Check to see if you have an old workspace being loaded. You might have an object called 'family' which you might need to remove. --sundar On Oct 11, 2009 12:15 PM, romunov romu...@gmail.com wrote: Thank you Jorge and Barry for your input. I've fiddled around a bit and as a result, am even more

Re: [R] How to speed up R with version 2.9.2?

2009-10-02 Thread Sundar Dorai-Raj
Another possibility is a very large .RData file in the directory where you're starting R. You can try Rgui --no-restore (I don't have windows, so I'm not sure if this an option with RGui, though I know it is with R.) --sundar On Fri, Oct 2, 2009 at 8:50 AM, Gabor Grothendieck

Re: [R] Skipping missing files when importing data

2009-09-20 Thread Sundar Dorai-Raj
Try ?file.exists. if (file.exists(fxxx)) { read.table(fxxx) } else { cat(\, fxxx, \ is missing\n, sep = ) } HTH, --sundar On Sun, Sep 20, 2009 at 9:28 PM, jiangrm jian...@gmail.com wrote: Trying to import a bunch of data files named like f001, f002, f999. Some of the files may be

Re: [R] xyplot: Can I identify groups but not use them for regression?

2009-09-18 Thread Sundar Dorai-Raj
I think this ought to work for you: library(lattice) set.seed(42) d - data.frame(year = c(rep(2007,12), rep(2008,12)), treatment = rep(LETTERS[1:3], each = 4, times = 2)) d$cover - rnorm(nrow(d)) d$variable - rnorm(nrow(d)) xyplot(variable ~ cover | year, d, panel =

Re: [R] Lattice graph tweaking

2009-08-25 Thread Sundar Dorai-Raj
A reproducible example would be nice. Try grid = FALSE for the first question, though I'm unaware which lattice plot you are using where the default is TRUE. So I can't guarantee that will even work. For your second question, add par.settings = list(strip.background = list(col = white)) to

Re: [R] Help with nls and error messages singular gradient

2009-08-25 Thread Sundar Dorai-Raj
Hi, Michael, I think the SPSS answer is wrong. Your starting values are way off. Look at this plot for verification: con - textConnection(time bod 11 0.47 22 0.74 33 1.17 44 1.42 55 1.60 67 1.84 79 2.19 8 11 2.17) mydata - read.table(con, header = TRUE) close(con)

Re: [R] Help with nls and error messages singular gradient

2009-08-25 Thread Sundar Dorai-Raj
Another alternative is to use SSlogis which is very similar to the model you're fitting except with one additional parameter: Asym - 3 xmid - 0 scal - 10 model - nls(bod ~ SSlogis(time, Asym, xmid, scal), data = mydata) summary(model) plot(bod ~ time, mydata) newdata - data.frame(time = seq(1,

Re: [R] how to check if ... is empty

2009-07-16 Thread Sundar Dorai-Raj
Try dots - list(...) if (length(dots) == 0) { ## do something } On Thu, Jul 16, 2009 at 6:46 AM, Thomas Roth (geb. Kaliwe)hamstersqu...@web.de wrote: Hi, I was wondering what would be the best way to check if the three dots argument contains any arguments (i.e. does ... contain any

Re: [R] Lattice group colors?

2009-06-22 Thread Sundar Dorai-Raj
Look at show.settings() and str(trellis.par.get()). This will show you what the default settings are. The group colors are set by the superpose.* elements (e.g. superpose.line is for group lines). To set them, I usually create a list and pass it to par.settings. For example, my.theme -

Re: [R] reading in multiple files

2009-06-09 Thread Sundar Dorai-Raj
You could try: do.call(rbind, lapply(list.files(path/to/files, full = TRUE), read.csv)) And add more arguments to lapply if the files are not csv, have no header, etc. --sundar On Tue, Jun 9, 2009 at 11:18 AM, Erin Hodgesserinm.hodg...@gmail.com wrote: Dear R People: I have about 6000 files

Re: [R] find a sequence of characters in a vector

2009-06-05 Thread Sundar Dorai-Raj
use gregexpr and paste aze - paste(c(a, z, e), collapse = ) sequence - paste(c(a,z,e,r,t,a,z,a,z,e,c), collapse = ) gregexpr(aze, sequence, fixed = TRUE) [[1]] [1] 1 8 attr(,match.length) [1] 3 3 HTH, --sundar On Fri, Jun 5, 2009 at 6:22 AM, Ptit_Bleuptit_b...@yahoo.fr wrote: Hello,

Re: [R] error message re: max(i), but code and output seen O.K.

2009-05-20 Thread Sundar Dorai-Raj
This error is thrown if the argument to max is either NULL or length zero: [~] Rscript -e max(NULL) [1] -Inf Warning message: In max(NULL) : no non-missing arguments to max; returning -Inf [~] Rscript -e max(numeric(0)) [1] -Inf Warning message: In max(numeric(0)) : no non-missing arguments to

Re: [R] what is wrong with this code?

2009-05-19 Thread Sundar Dorai-Raj
You're missing a ) off end of the first line. You should consider using an editor (e.g. ESS/Emacs) that does parentheses matching. I found this in less than 5 sec (less time than I'm taking to write you a note) by cut and pasting in Emacs. --sundar On Tue, May 19, 2009 at 12:52 PM, deanj2k

Re: [R] convert large integers to hex

2009-05-07 Thread Sundar Dorai-Raj
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. x=6595137340052185552 obase=16 x 5B86A277DEB9A1D0 You can call this from R. On Wed, May 6, 2009 at 3:26 PM, Sundar Dorai-Raj sdorai

[R] convert large integers to hex

2009-05-06 Thread Sundar Dorai-Raj
Hi, I'm wondering if someone has solved the problem of converting very large integers to hex. I know about format.hexmode and as.hexmode, but these rely on integers. The numbers I'm working with are overflowing and losing precision. Here's an example: x - 6595137340052185552 # stored as

Re: [R] setting trellis auto.key color values

2009-05-05 Thread Sundar Dorai-Raj
Set the colors in graph.sets and not auto.key. graph.sets - list(axis.text = list(cex = 0.65), par.ylab.text = list(cex = 1.25), par.xlab.text = list(cex = 1.25), superpose.polygon = list(col = 3:5)) Then remove the col = 3:5 from auto.key and barchart.

Re: [R] evaluate a expression

2009-05-02 Thread Sundar Dorai-Raj
Hi, Ning, Try: eval(parse(text = expr)) HTH, --sundar On Sat, May 2, 2009 at 5:39 AM, Ning Ma pnin...@gmail.com wrote: Hi, I am new to R. Can anyone tell me how to evaluate an expression stored in a string? such as: expr - 3*5 I want to get the result 15. Thanks in advance.

Re: [R] Flipping axes of qqnorm

2009-04-26 Thread Sundar Dorai-Raj
Try (re)reading ?qqnorm. Use datax = TRUE. --sundar On Sun, Apr 26, 2009 at 4:37 PM, Chris_d dewhurstch...@gmail.com wrote: Hi all,       I have just started using R to produce qqnorm plots. I am trying to switch the x and y axes so that the theoretical values are plotted on the y axis and

Re: [R] Cannot clean infinite values

2009-04-26 Thread Sundar Dorai-Raj
Use ?is.infinite inf - is.infinite(data) data[inf] - 0.3 * sign(data[inf]) On Sun, Apr 26, 2009 at 5:44 PM, Nigel Birney na...@cam.ac.uk wrote: Hello all, I have to import numeric data from file but found it contains Infinite values which need to be eliminated. I tried to replace them in

Re: [R] Setting lattice par parameters

2009-04-23 Thread Sundar Dorai-Raj
Because you're not calling trellis.par.set correctly. It should be: trellis.par.set(par.ylab.text = list(cex = 0.65), par.xlab.text = list(cex = 0.65)) However, I usually do things like this: my.theme - list(par.ylab.text = list(cex = 0.65), par.xlab.text = list(cex = 0.65)) barchart(...,

Re: [R] question on using lattice panel plots

2009-04-16 Thread Sundar Dorai-Raj
Try: z - cbind(rep(c(BIC, hist), each = 150), rep(rep(c(5, 10, 30), each = 50),2)) z - as.data.frame(z) z - cbind(z, runif(300)) names(z) - c(Method, sigma, Error) z$sigma - factor(z$sigma, c(5, 10, 30)) library(lattice) sigma - as.numeric(levels(z$sigma)) sigmaExprList - lapply(sigma,

Re: [R] question on using lattice panel plots

2009-04-16 Thread Sundar Dorai-Raj
, ...) }, layout = c(3,1)) Not sure how to do this with strip.custom. --sundar On Thu, Apr 16, 2009 at 1:20 PM, Sundar Dorai-Raj sdorai...@gmail.com wrote: Try: z - cbind(rep(c(BIC, hist), each = 150), rep(rep(c(5, 10, 30), each = 50),2)) z - as.data.frame(z) z - cbind(z, runif(300

Re: [R] Changing the y-axis units of a lattice histogram

2009-04-03 Thread Sundar Dorai-Raj
Try: library(lattice) histogram( ~ height | voice.part, data = singer, type = c, scales = list(y = list(at = seq(0, 20, 5), labels = seq(0, 200, 50 HTH, --sundar On Fri, Apr 3, 2009 at 2:01 PM, Judith Flores jur...@yahoo.com wrote: Hello,

Re: [R] labeling panels in lattice plots

2009-03-31 Thread Sundar Dorai-Raj
Try converting year to a factor xyplot(min + max + ave ~ month | factor(year), data = rain.stats, ...) Also, notice the inclusion of the data argument. HTH, --sundar On Tue, Mar 31, 2009 at 6:28 AM, steve_fried...@nps.gov wrote: I am using windows XP with R 2.8.1 I am generating a

Re: [R] Can not get a prediction interval from Predict

2009-03-31 Thread Sundar Dorai-Raj
?predict.glm has no interval argument. Perhaps you're thinking of ?predict.lm, which is different. To get intervals in glm, I've used: example(predict.glm) pr - predict(budworm.lg, se.fit = TRUE) family - family(budworm.lg) lower - family$linkinv(pr$fit - qnorm(0.95) * pr$se.fit) upper -

Re: [R] use R Group SFBA April meeting reminder; video of Feb k

2009-03-30 Thread Sundar Dorai-Raj
Could be that you have some sort of ad filter in your browser that's blocking the video? It appears just fine for me in Firefox 3. On Mon, Mar 30, 2009 at 3:55 PM, Ted Harding ted.hard...@manchester.ac.uk wrote: On 30-Mar-09 22:13:04, Jim Porzak wrote: Next week Wednesday evening, April 8th,

Re: [R] Requesting help with lattice again

2009-03-25 Thread Sundar Dorai-Raj
For the first question, add a groups argument. E.g. barchart(HSI ~ Scenario | Region, Wbirdsm, groups = HydroState) Also note that using Wbirdsm$HSI makes your call less readable, so I added the data argument. For your second question, setting the key does not set the color theme. You want to

Re: [R] XYplot simple question

2009-03-16 Thread Sundar Dorai-Raj
Convert Plot to factor: xyplot(AbvBioAnnProd ~ Year | Plot, type = c(b, r), pch = 16) Also note that using the type argument with multiple values prevents the necessity of a custom panel function. HTH, --sundar On Mon, Mar 16, 2009 at 5:54 AM, AllenL allen.laroc...@gmail.com wrote: Hello R

Re: [R] XYplot simple question

2009-03-16 Thread Sundar Dorai-Raj
Sorry, I should have xyplot(AbvBioAnnProd ~ Year | factor(Plot), type = c(b, r), pch = 16) On Mon, Mar 16, 2009 at 6:17 AM, Sundar Dorai-Raj sdorai...@gmail.com wrote: Convert Plot to factor: xyplot(AbvBioAnnProd ~ Year | Plot, type = c(b, r), pch = 16) Also note that using the type

Re: [R] Get user system name

2009-03-16 Thread Sundar Dorai-Raj
Assuming USER is defined on your system then Sys.getenv(USER) ought to work. --sundar On Mon, Mar 16, 2009 at 3:04 PM, Etienne Bellemare Racine etienn...@gmail.com wrote: I would like to get the name of the user form the system. Is it possible ? Something like  system.user() returning

Re: [R] Get user system name

2009-03-16 Thread Sundar Dorai-Raj
. Is there a workaround or another solution ? -- Etienne Sundar Dorai-Raj a écrit : Assuming USER is defined on your system then Sys.getenv(USER) ought to work. --sundar On Mon, Mar 16, 2009 at 3:04 PM, Etienne Bellemare Racine etienn...@gmail.com wrote: I would like to get the name

Re: [R] Matrix Construction; Subdiagonal

2009-03-11 Thread Sundar Dorai-Raj
Does this help? A - matrix(0, 6, 6) vec - 1:5 A[row(A) == col(A) + 1] - vec --sundar On Wed, Mar 11, 2009 at 4:42 PM, Stu Field s...@colostate.edu wrote: I'm trying to enter a vector into the subdiagonal of a matrix but cannot find a command in R which corresponds to the MatLab version of

Re: [R] Matrix Construction; Subdiagonal

2009-03-11 Thread Sundar Dorai-Raj
, thanks. But I guess I was looking for something more similar to MatLab, I'm really surprised R doesn't have a preset command for this (?) Thanks again, Stu On 11 • Mar • 2009, at 5:49 PM, Sundar Dorai-Raj wrote: Does this help? A - matrix(0, 6, 6) vec - 1:5 A[row(A) == col(A) + 1] - vec

Re: [R] Lattice: Customizing point-sizes with groups

2009-03-10 Thread Sundar Dorai-Raj
Try this: xyplot(y ~ x, temp, groups = groups, par.settings = list( superpose.symbol = list( cex = c(1, 3), pch = 19, col = c(blue, red See: str(trellis.par.get()) for other settings you might want to change. Also, you should drop the ;

Re: [R] Lattice: Customizing point-sizes with groups

2009-03-10 Thread Sundar Dorai-Raj
= temp$cex, col = temp$col, pch = 19); Once I introduce groups, I lose the ability to customize individual data-points and seem only to be able to customize entire groups. Paul -Original Message- From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] Sent: Tuesday, March 10, 2009 5:49

Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Sundar Dorai-Raj
Convert Year to a factor and both problems will be solved. --sundar On Tue, Mar 10, 2009 at 3:48 PM, jimdare jamesdar...@gmail.com wrote: Hi, I have created the plot below and have a few questions about changes. 1) How do I change the Year title of each plot so it reads from the top

Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Sundar Dorai-Raj
I don't believe Elena's suggestion will work. However, the following will: xyplot(..., scales = list(y = list(at = seq(5, 25, 5 though you may need to extend the limits a little as well: xyplot(..., ylim = lattice:::extend.limits(c(0, 30))) and add the scales argument from the first

Re: [R] Date conversion

2009-03-05 Thread Sundar Dorai-Raj
Hi, There are possibly several ways to do this. My approach would be: dates - strptime(as.character(DATE), %d%b%Y) year - dates$year + 1900 week - floor(dates$yday/365 * 52) HTH, --sundar On Thu, Mar 5, 2009 at 8:58 AM, Pele drdi...@yahoo.com wrote: Hi R users, I have a factor variable

Re: [R] lattice: remove box around a wireframe

2009-03-04 Thread Sundar Dorai-Raj
(Sorry for the repeat. Forgot to copy R-help) Try, test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, par.settings = list(axis.line = list(col = transparent)), par.box = c(col

Re: [R] levelplot help needed

2009-02-27 Thread Sundar Dorai-Raj
To reorder the y-labels, simply reorder the factor levels: df - data.frame(x_label = factor(x_label), y_label = factor(y_label, rev(y_label)), values = as.vector(my.data)) Not sure about putting the strips at the bottom. A quick scan of ?xyplot and

Re: [R] lattice contourplot line types

2009-02-22 Thread Sundar Dorai-Raj
The only way I can figure out to do this is to use two calls to panel.contourplot: library(lattice) x - seq(-2, 2, length = 20) y - seq(-2, 2, length = 20) grid - expand.grid(x=x, y=y) grid$z - dnorm(grid$x) * dnorm(grid$y) contourplot(z ~ x * y, grid, panel = function(at, lty, col,

Re: [R] Uninstall question

2009-02-17 Thread Sundar Dorai-Raj
This is on the Mac FAQ: http://cran.cnr.berkeley.edu/bin/macosx/RMacOSX-FAQ.html#How-can-R-for-Mac-OS-X-be-uninstalled_003f HTH, --sundar On Tue, Feb 17, 2009 at 7:17 AM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: I need to uninstall R 2.7.1 from my Mac. What is the best way to

Re: [R] Adding abline in Lattice graph

2009-02-12 Thread Sundar Dorai-Raj
Try: coplot(lbxglu~lbxgh|eth, data = reg.dat.5, panel= function(...) { panel.smooth(...) panel.abline(h = 126, col = red) panel.abline(v = 6.5, col = blue) }, xlab=ABC, ylab=FBG) Also note that you removed your with call and give coplot a data argument. HTH, --sundar On

Re: [R] Adding abline in Lattice graph

2009-02-12 Thread Sundar Dorai-Raj
, Sundar Dorai-Raj sdorai...@gmail.com wrote: Try: coplot(lbxglu~lbxgh|eth, data = reg.dat.5, panel= function(...) { panel.smooth(...) panel.abline(h = 126, col = red) panel.abline(v = 6.5, col = blue) }, xlab=ABC, ylab=FBG) Also note that you removed your with call and give

Re: [R] changing settings on a barchart (lattice)

2009-02-11 Thread Sundar Dorai-Raj
! Dimitri On Wed, Feb 11, 2009 at 12:46 PM, Sundar Dorai-Raj sdorai...@gmail.com wrote: Pass a list to xlab and main for the font sizes: barchart(..., xlab = list(x-axis, cex = 2), main = list(title, cex = 2)) For value labels and a grid you'll need a custom panel function: barchart(..., panel

Re: [R] Efficent way to create an nxn upper triangular matrix of one's

2009-02-11 Thread Sundar Dorai-Raj
Try x - diag(n) x[upper.tri(x)] - 1 On Wed, Feb 11, 2009 at 1:22 PM, Dale Steele dale.w.ste...@gmail.com wrote: The code below create an nxn upper triangular matrix of one's. I'm stuck on finding a more efficient vectorized way - Thanks. --Dale n - 9 data - matrix(data=NA, nrow=n, ncol=n)

Re: [R] sapply

2009-02-08 Thread Sundar Dorai-Raj
I'm not sure what you really want, so perhaps a simple example would help (i.e. what a sample of the input looks like and what the output you need looks like). My guess would be sapply(df, diff) but again, I'm not sure. --sundar On Sun, Feb 8, 2009 at 4:24 PM, glenn

Re: [R] subsets problem

2009-02-08 Thread Sundar Dorai-Raj
you can try lapply(lapply(uniques, function(x) subset(df, date == x)), myfun) or possibly more accurate (subset may be finicky due to scoping): lapply(lapply(uniques, function(x) df[df$date == x, ]), myfun) or use ?split lapply(split(df, df$date), myfun) HTH, --sundar On Sun, Feb 8, 2009

Re: [R] Foreign function call

2009-02-04 Thread Sundar Dorai-Raj
You're missing that R_TSConv is an R object. You can use stats:::R_TSConv to see the value. Not sure how this helps you though. On Wed, Feb 4, 2009 at 10:08 AM, rkevinbur...@charter.net wrote: Let me get more specific. I think it this can be answered then I can translate the information to

Re: [R] color and fontfamily in lattice

2009-02-03 Thread Sundar Dorai-Raj
Try this: dados - data.frame(varsep = factor(rep(1:2,10)), i = runif(20)) library(lattice) font.settings - list( font = 2, cex = 2, fontfamily = serif) my.theme - list( box.umbrella = list(col = red), box.rectangle = list(col =

Re: [R] xyplot with lowess curves

2009-02-02 Thread Sundar Dorai-Raj
You'll need a custom panel function. It would also help if you provided a reproducible example: xyplot ( SnowLineElevation ~ Year | Model, data = data, panel = function(x, y, col, ...) { col - ifelse(panel.number() == 1, red, green) panel.xyplot(x, y, col = blue, ...)

Re: [R] xyplot with lowess curves

2009-02-02 Thread Sundar Dorai-Raj
Elevation [m]' ) -Original Message- From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] Sent: Monday, February 02, 2009 11:43 AM To: Hutchinson,David [PYR] Cc: r-help@r-project.org Subject: Re: [R] xyplot with lowess curves You'll need a custom panel function. It would also help if you

Re: [R] Assigning colnames in loop

2009-02-02 Thread Sundar Dorai-Raj
It's always best to do this with list operations (e.g. lapply) rather than a loop: DF1 - split(DF, DF$male) DF2 - lapply(DF1, function(x) { x2 - t(as.matrix(x[3:5], dimnames = list(levels(x$age), NULL))) as.data.frame(x2) }) Then DF2[[0]] and DF2[[1]] are the data.frames you want. HTH,

Re: [R] capturing stderr/stdout

2008-11-21 Thread Sundar Dorai-Raj
://perl.plover.com/FAQs/Buffering.html Sundar Dorai-Raj wrote: Hi, I have an application in perl that prints some output to either stderr or stdout. Here's an example: # tmp.pl print STDERR starting iterator\n; for(my $i = 0; $i 100; $i++) { print $i . \n; } # tmp.R con - pipe(perl

[R] capturing stderr/stdout

2008-11-20 Thread Sundar Dorai-Raj
Hi, I have an application in perl that prints some output to either stderr or stdout. Here's an example: # tmp.pl print STDERR starting iterator\n; for(my $i = 0; $i 100; $i++) { print $i . \n; } # tmp.R con - pipe(perl tmp.pl) r - readLines(con, n = -1) close(con) However, the

Re: [R] determining plot location in lattice

2008-11-08 Thread Sundar Dorai-Raj
the plot finishes). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Sundar Dorai-Raj Sent: Friday, November 07

[R] determining plot location in lattice

2008-11-07 Thread Sundar Dorai-Raj
Hi, I'm dealing with a lattice plot inserted into a tk widget and would like to know when a user has clicked on the plot area of a plot (i.e. inside the axes). For example, library(tkrplot) library(lattice) tt - tktoplevel() makePlot - function() print(xyplot(1 ~ 1)) printCoords -

Re: [R] tklistbox selection

2008-10-30 Thread Sundar Dorai-Raj
I solved this problem by adding exportselection = 0 to the call to tklistbox. I.e. tb1 - tklistbox(tt, listvariable = tcl1, exportselection = 0, selectmode = multiple) Thanks, --sundar Sundar Dorai-Raj said the following on 10/29/2008 5:56 PM: Hi, I'm

[R] tklistbox selection

2008-10-29 Thread Sundar Dorai-Raj
Hi, I'm posting yet another question about tcltk since I'm still struggling with the package. I'm trying to create a tklistbox and a ttkcombobox on the same parent and am having a problem. Here's an example: library(tcltk) tt - tktoplevel() tcl1 - tclVar() tcl2 - tclVar() tclObj(tcl1) -

[R] ttkcombobox

2008-10-27 Thread Sundar Dorai-Raj
Hi, all, (sessionInfo at the end) I've been struggling with the tcltk package and can't seem to get the ttkcombobox to work. Here's an example: library(tcltk) p - tktoplevel() l - tclVar() ## I don't know if I'm even calling it correctly cb - ttkcombobox(p, values = letters[1:4],

Re: [R] ttkcombobox

2008-10-27 Thread Sundar Dorai-Raj
] On Behalf Of Sundar Dorai-Raj Sent: Monday, October 27, 2008 3:02 PM To: r-help@r-project.org Subject: [R] ttkcombobox Hi, all, (sessionInfo at the end) I've been struggling with the tcltk package and can't seem to get the ttkcombobox to work. Here's an example: library(tcltk) p - tktoplevel() l

Re: [R] using bquote to construct function

2008-10-02 Thread Sundar Dorai-Raj
)}) function(x) {x^.(z)} bquote(function(x, y) { x^.(z) + y}) function(x, y) { x^.(z) + y} R.version.string # Vista [1] R version 2.7.2 (2008-08-25) Try it this way: z - 2 f - function(x, y) {} body(f) - bquote({ x^.(z) + y }) eval(f)(2, 3) On Thu, Oct 2, 2008 at 1:14 AM, Sundar Dorai-Raj

[R] using bquote to construct function

2008-10-01 Thread Sundar Dorai-Raj
Hi, R-help, (sessionInfo at the end) I'm trying to construct a function using bquote and running into a strange error message. As an example, what I would like to do is this: z - 2 eval(bquote(function(x, y) { x^.(z) + y }))(2, 3) However, I get the following: Error in eval(expr, envir,

Re: [R] use expression() in a loop

2008-08-18 Thread Sundar Dorai-Raj
Nanye Long said the following on 8/18/2008 3:00 PM: Hi all, I want to do plot() in a loop to make 10 graphs, so I have some code like for (i in 1:10) { plot(... ... , xlab = expression(g[i]) ) } I expect g_1, g_2, and so on appear on x labels, but it simply prints g_i for each graph.

Re: [R] upgrade to 2.5

2008-07-31 Thread Sundar Dorai-Raj
Iasonas Lamprianou said the following on 5/2/2007 8:25 AM: Hi I am using R version 2.4.1. How can I upgrade to version 2.5 without having to install all the packages again? Thanks Jason You may find the following link relevant.

Re: [R] Accessing items in a list of lists

2008-05-14 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] said the following on 5/14/2008 12:40 PM: Using R 2.6.2, say I have the following list of lists, comb: data1 - list(a = 1, b = 2, c = 3) data2 - list(a = 4, b = 5, c = 6) data3 - list(a = 3, b = 6, c = 9) comb - list(data1 = data1, data2 = data2, data3 = data3) So that all

Re: [R] as.numeric with tclvalue redux

2008-03-24 Thread Sundar Dorai-Raj
Erin Hodgess said the following on 3/24/2008 10:39 AM: Hi again R People: This works fine: library(tcltk) a - tclVar(4.5) as.numeric(tclvalue(a)) [1] 4.5 #But if you have: b - tclVar(pi) as.numeric(tclvalue(b)) [1] NA Warning message: NAs introduced by coercion Is anyone aware

Re: [R] Lme does not work without a random effect (UNCLASSIFIED)

2008-03-14 Thread Sundar Dorai-Raj
Park, Kyong H Mr ECBC said the following on 3/14/2008 12:25 PM: Classification: UNCLASSIFIED Caveats: NONE Dear R users, I'm interested in finding a random effect of the Block in the data shown below, but 'lme' does not work without the random effect. I'm not sure how to group the

Re: [R] Distances between two datasets of x and y co-ordinates

2008-03-12 Thread Sundar Dorai-Raj
Andrew McFadden said the following on 3/12/2008 1:47 PM: Hi all I am trying to determine the distances between two datasets of x and y points. The number of points in dataset One is very small i.e. perhaps 5-10. The number of points in dataset Two is likely to be very large i.e.

Re: [R] LaTeX in R

2008-03-07 Thread Sundar Dorai-Raj
Or my personal favorite if the length of mySigma is variable: mySigma - 2:3 plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l') lines(dnorm(1:10,sd = mySigma[2]),lty = 2) leg - as.expression(lapply(mySigma, function(x) bquote(sigma == .(x legend(x = topright, lty = c(1,2),legend = leg)

Re: [R] wire.frame tick labels from matrix

2008-02-15 Thread Sundar Dorai-Raj
Marlin Keith Cox said the following on 2/15/2008 11:39 AM: Dear R Users, close to the end of this I used wireframe to create a 3D plot from a matrix. The x and y axis tick labels (1-6) for each were created from the matrix being a 6X6 matrix. I need the axis tick labels to be the row and

Re: [R] fun.aggregate=mean in reshape

2008-02-12 Thread Sundar Dorai-Raj
[Ricardo Rodriguez] Your XEN ICT Team said the following on 2/12/2008 12:23 AM: Hi all, We are facing a problem while introducing ourselves to Reshape package use. Melt seems to work fine, but cast fails when we use mean as fun.aggregate. As you see here, length and sum work fine, but

Re: [R] lattice color problem with symbols: bug?

2008-01-11 Thread Sundar Dorai-Raj
Stefan Grosse said the following on 1/11/2008 10:04 AM: Dear useR's, I have a problem with the lattice plotting of some symbols: library(lattice) test-data.frame(x=c(2,3,1,5),u=c(rep(1,2),rep(2,2)),g=c(rep(c(1,2),2))) xyplot(x~u,groups=g, data=test, par.settings=list(

Re: [R] side by side plots

2008-01-07 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] said the following on 1/7/2008 2:59 PM: Hello everyone, I have an overlay plot it's nice but you can't see all the data. I would like to know if there is a way to get a plot that gives a side by side plot so that each plot would be next to each other. The two plots have

Re: [R] mfrow for levelplot?

2008-01-05 Thread Sundar Dorai-Raj
marcg said the following on 1/5/2008 3:48 AM: hello could anyone tell my, why I do not suceed with mfrow? par(mfrow=c(4,4)) for (i in 5:17){ levelplot(maxwater[,i]~maxwater$V1*maxwater$V2, col.regions=whiteblue(5), xlab=, cuts=4) } Thanks Marc -- Because par

Re: [R] Accesing the value

2007-12-28 Thread Sundar Dorai-Raj
get(x) This is a FAQ: http://cran.cnr.berkeley.edu/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f --sundar Shubha Vishwanath Karanth said the following on 12/28/2007 8:38 AM: Hi R, x=A A=5 I need to get the value of A using x only. How do I do this?

Re: [R] How can R be used to solve algebra equations?

2007-11-29 Thread Sundar Dorai-Raj
francogrex said the following on 11/29/2007 1:00 PM: suppose I have this equation: (x^2+y^2+3z^3)/(5*z^2*x^3)=0 and I want to find x in relation to the other variables which actually is: x=sqrt(-3*z^3-y^2) or x=-sqrt(-3*z^3-y^2) Can R give me this expression solution? I know there is

Re: [R] cumsum

2007-11-03 Thread Sundar Dorai-Raj
threshold said the following on 11/3/2007 4:41 AM: Hi, my problem belongs to the basic ones. I want to get cumulated sum over the matrix columns by one command (if such exists). Ordinary R's cumsum(x) when x is: [,1] [,2] [1,]15 [2,]26 [3,]37 [4,]48

Re: [R] plot for binomial glm

2007-10-28 Thread Sundar Dorai-Raj
Radek John said the following on 10/28/2007 5:53 AM: Hello everybody! I am trying to plot glm with family=binomial and can`t work it out. My Data are: mort temp num numdead 132 7 0 232 8 0 332 8 0 437 15 3 537 15 1 637

Re: [R] Wildcards

2007-10-15 Thread Sundar Dorai-Raj
subura said the following on 10/15/2007 12:04 PM: Care to explain how i can use a wildcard expression to source all files ending with .R in a subdirectory ? I've tried something like this 'source(glob2rx(*.R))' without success. Thank you Try R.files - list.files(my.path, pattern =

Re: [R] use 'lapply' to creat 2 new columns based on old ones in a data frame

2007-10-12 Thread Sundar Dorai-Raj
runner said the following on 10/12/2007 4:46 PM: There is a dataset 'm', which has 3 columns: 'index', 'old1' and 'old2'; I want to create 2 new columns: 'new1' and 'new2' on this condition: if 'index'==i, then 'new1'='old1'+add[i]. 'add' is a vector of numbers to be added to old columns,

[R] Checking for adequate disk space

2007-10-03 Thread Sundar Dorai-Raj
Hi, all, (version info at end) I'm running a script which takes input files, does some analysis, and writes the output to csv files. Last night I ran the script (it took ~6.5 hours) thinking all would go well since it ran on a subset of the data without issue. However, when I returned this

  1   2   >