Re: [R] create arrays

2011-05-06 Thread Greg Snow
?seq -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Schatzi Sent: Friday, May 06, 2011 1:12 PM To:

Re: [R] Using error in histograms

2011-05-05 Thread Greg Snow
The logspline package does density estimation in a different way than KDE, but it does allow for interval censored data (I know this value is between a and b, but not where in that range) using the oldlogspline function. This may be what you are looking for. -- Gregory (Greg) L. Snow Ph.D.

Re: [R] Insert values to histogram

2011-05-05 Thread Greg Snow
Are you really sure that you want to do that? Read the discussion starting with this post: http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html for reasons why you probably don't (yes, the question is about bar plots not histograms, but much of it will still apply). Near the end of the

Re: [R] perspective plot

2011-05-05 Thread Greg Snow
The persp function expects z to be a matrix, so you could reshape your data so that z is a matrix (the reshape function or package may help). Or the wireframe function in the lattice package expects data more like what you show, that may be the easiest solution. -- Gregory (Greg) L. Snow

Re: [R] Controlling the extent of ablines on plot

2011-05-03 Thread Greg Snow
Check your par() settings, specifically xpd. For more control see ?clip. If that does not do enough for you then use lines or segments for complete control. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original

Re: [R] data transformation ----Box-Cox Transformations

2011-05-03 Thread Greg Snow
There is the bct function in the TeachingDemos package that does Box-Cox transforms (though you could also write your own fairly simply). The lappy/sapply functions will apply a function to each column of a data frame. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

Re: [R] Constructing a histogram with words as labels as height as frequency?

2011-05-03 Thread Greg Snow
?barplot -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Caitlin Sent: Tuesday, May 03, 2011 11:36 AM To:

Re: [R] Change the names of a dataframe

2011-05-03 Thread Greg Snow
In the first case you create a new data frame consisting of the 2nd column of the original, then change the name of the only column in that new data frame, then since nothing is done with that data frame it gets thrown away. So it is not that nothing happened, but just that nothing useful

Re: [R] QQ plot for normality testing

2011-05-02 Thread Greg Snow
I would use the vis.test function along with vt.qqnorm (both in TeachingDemos package). This will create several plots, one of which is your data, the rest are simulated normals with the same mean and standard deviation. If you can tell which plot stands out (and it is your real data) then

Re: [R] Kolmogorov-Smirnov test

2011-04-29 Thread Greg Snow
The general idea of the KS test (and others) can be applied to discrete data, but the implementation in R assumes continuous data (does not have the needed adjustments to deal with ties). The chi-square and other tests suffer from the same problems in your case. In all cases the null

Re: [R] Retrieving call sequence leading to a plot / Zooming in maps

2011-04-28 Thread Greg Snow
You could always put the commands into a script or function, then instead of retyping everything just run the script or function. There is the zoomplot function in the TeachingDemos package which does what you are suggesting (but my quick test did not work with your map). You could use that

Re: [R] Kolmogorov-Smirnov test

2011-04-28 Thread Greg Snow
A couple of things to consider: The Kolmogorov-Smirnov test is designed for distributions on continuous variable, not discrete like the poisson. That is why you are getting some of your warnings. With a sample size over 10,000 you will have power to detect differences that are not

Re: [R] density plot of simulated exponential distributed data

2011-04-27 Thread Greg Snow
You might want to use the logspline package instead of the density function, it allows you to specify bounds on a distribution. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] str() without any details - only structure? (removing elements from list)

2011-04-27 Thread Greg Snow
Look at TkListView in the TeachingDemos package as one option (though for large lists it is noticeably slower than str). It creates a tree structure representing your list that you can then expand or collapse branches in. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

Re: [R] Two Copies of Each Message

2011-04-22 Thread Greg Snow
Do you have 2 e-mail addresses (or 2 versions of your email address) subscribed to the list? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org

Re: [R] Two Questions

2011-04-20 Thread Greg Snow
When running a large number of commands from a script that produces multiple plots it is often best to send the plots to the pdf device (or other system) that you can then page through after it is finished. You could also specify par(ask=TRUE) then you would be prompted before changing the

Re: [R] str() on a data frame with 600 variables

2011-04-19 Thread Greg Snow
An alternative that you may find interesting is the TkListView function in the TeachingDemos package. This opens a separate window and shows the list structure there with options for scrolling and expanding/collapsing sublists. You will probably need to be a little patient while the display

Re: [R] simple user input

2011-04-19 Thread Greg Snow
If you don't need the web browser part then look at the tkexamp function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org

Re: [R] Overlaying images at nodes of phylogenetic tree

2011-04-19 Thread Greg Snow
A couple of possibilities: The rasterImage function (in the graphics package) The my.symbols and ms.image functions in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message-

Re: [R] Alignment of lines within barplot bars

2011-04-18 Thread Greg Snow
Sorry I took so long to get back on this, I have been out of town. For your case you need to provide adjustments for both the x and y to updateusr, try this: library(TeachingDemos) tmp - barplot(c(1.5,40),yaxt='n',names.arg=1:2,ylim=c(0,1.25*40)) axis(4) tmp2 - par('usr') updateusr(tmp[1:2],

Re: [R] A question about txtProgressBar function

2011-04-18 Thread Greg Snow
If your loop is producing its own output then you probably should not use txtProgressBar, but you can use either winProgressBar (if on windows) or tkProgressBar (on all platforms, but need tcltk package). These open an additional window with the progress bar and any additional information that

Re: [R] multiple lines on multiple plots

2011-04-18 Thread Greg Snow
Going back to a previous graph does not automatically restore the coordinate system (as you noticed). But you can store that information (lot less info than your data in most cases) and reset it manually. Try: x- 1:10 y- (1:100)*3 par(mfcol=c(2,1)) plot(x) tmp1 - par('usr') plot(y) tmp2 -

Re: [R] Randomisation tests

2011-04-08 Thread Greg Snow
For simple permutation tests I usually just code it up in regular R without worrying about any packages. R is powerful enough that it is simple to do a permutation test in only a few lines ( or sometimes just one long line). And that way you know exactly what it is doing. -- Gregory (Greg)

Re: [R] Alignment of lines within barplot bars

2011-04-08 Thread Greg Snow
Look at the updateusr function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of

Re: [R] plot layout with several plots ON plot area of previous plot

2011-04-08 Thread Greg Snow
Some of the functions that were the first in the TeachingDemos package were originally written to help me visualize something, so it is not just teachers demoing, but people demoing to themselves. It has become a bit of a misc package with several utilities that are useful in themselves, but

Re: [R] power of 2 way ANOVA with interaction

2011-04-04 Thread Greg Snow
You can use simulation: 1. decide what you think your data will look like 2. decide how you plan to analyze your data 3. write a function that simulates a dataset (common arguments include sample size(s) and effect sizes) then analyzes the data in your planned manner and returns the p-value(s)

Re: [R] kernel density plot

2011-04-03 Thread Greg Snow
It is better to replace your later calls to plot with calls to lines instead, then you don't need to use par(new=T) which as you see tends to cause problems. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original

Re: [R] kernel density plot

2011-04-03 Thread Greg Snow
[mailto:muzna.a...@gmail.com] Sent: Sunday, April 03, 2011 12:52 PM To: Greg Snow Cc: r-help@r-project.org Subject: Re: [R] kernel density plot i am sorry greg, can you explain that with an example? On Mon, Apr 4, 2011 at 12:11 AM, Greg Snow greg.s...@imail.orgmailto:greg.s...@imail.org wrote

Re: [R] How to put line linking two plots

2011-03-31 Thread Greg Snow
Here is a way to do it using just base graphics: layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE)) plot(runif(10), type='b', ylim=c(0,1)) x.tmp - grconvertX(4, to='ndc') y.tmp - grconvertY(0.9, to='ndc') plot(runif(20), type='l', ylim=c(0,1)) par(xpd=NA) segments( 10, 1, grconvertX(x.tmp,

Re: [R] Graph many points without hiding some

2011-03-31 Thread Greg Snow
Just a note, Base graphics does support transparency as long as the device plotting to supports it. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org

Re: [R] statistical question

2011-03-31 Thread Greg Snow
You could do bootstrapping for confidence intervals or permutation tests for just comparing the medians. There are other tools as well, just be sure that you understand what you are testing and what assumptions are being made in whatever method you choose. -- Gregory (Greg) L. Snow Ph.D.

Re: [R] generate random numbers

2011-03-31 Thread Greg Snow
There are several non-normal distributions built in that you could just use their generationg functions. There are packages (most with dist somewhere in the name) that allow for functions on standard distributions including combining together distributions. If your distribution is not one of

Re: [R] Creating 3 vectors that sum to 1

2011-03-30 Thread Greg Snow
] Sent: Tuesday, March 29, 2011 4:41 PM To: Greg Snow Cc: r-help@r-project.org Subject: Re: RE: [R] Creating 3 vectors that sum to 1 Hi Greg, Thanks. Here is one approach to speeding up the 1st method that I had suggested: n - 1 set.seed(123) rtrg - matrix(NA, n, 3) system.time

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Greg Snow
Do a search for Dirichlet, that may give you the tools you need. Also for plotting 3 vectors that sum to 1, instead of a 3d scatter plot you should look into a triangle or trilinear plot, see ?triplot in the TeachingDemos package (the see also for that help page lists several other

Re: [R] producing histogram-like plot

2011-03-29 Thread Greg Snow
Look at the cut, tapply, and barplot functions. There is probably also a nice way to do this using ggplot2 package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Greg Snow
PM To: Ravi Varadhan Cc: Greg Snow; r-help@r-project.org Subject: Re: [R] Creating 3 vectors that sum to 1 Here is an exploration of two different 3-tuple generators (that sum to 1) based on Greg's triplot function: require(TeachingDemos) n - 1000 rtrg - matrix(NA, n, 3) for (i

Re: [R] export data to gnuplot

2011-03-28 Thread Greg Snow
There is a fairly basic interface with gnuplot in the TeachingDemos package, see ?gp.open -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-

Re: [R] Coordinates of the text region

2011-03-26 Thread Greg Snow
Look at the strwidth and strheight functions. Also note the adj parameter (see ?par for details). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org

Re: [R] Comparing non nested models with correlation coefficients (inspired from Lorch and Myers )

2011-03-24 Thread Greg Snow
Well this starts veering towards fortune(194) and fortune(218). Though I did one time receive a response from an editor and reviewers asking for fewer p-values in favor of more confidence intervals. I was excited that someone was willing to move in that direction (unfortunately, that

Re: [R] Comparing non nested models with correlation coefficients (inspired from Lorch and Myers )

2011-03-23 Thread Greg Snow
If you are interested in the fits, then I would just plot the fits. Plot the fitted/predicted values from the 1st model as the x-values and the fitted/predicted values from the second model as the y-values. It is best to plot on a square plotting region and use asp=1, probably also doing

Re: [R] stacked bar plot

2011-03-23 Thread Greg Snow
You can use the tapply function to sum within combinations, then pass the results to barplot (possibly doing a reshape first). Also look at the ggplot2 package, it may do the summing as part of the plot call and probably does not need the reshape step. -- Gregory (Greg) L. Snow Ph.D.

Re: [R] Sample size of longitudinal and skewed data

2011-03-23 Thread Greg Snow
You can use simulation: 1. Simulate a dataset from what you believe the distribution and relationship to be. 2. Analyze the simulated data in the manner you plan 3. Determine if the results are significant Repeat the above many times keeping track of the sifnificances. The percent significant

Re: [R] Data frame and function that requires vector as input

2011-03-23 Thread Greg Snow
If a is a vector with missing values and b is the result of the function call that has just the non-missing computations on a, then you can do something like: newdat - rep(NA, length(a)) newdat[ !is.na(a) ] - b Sometimes the which and match functions can be useful as well. -- Gregory (Greg)

Re: [R] linear regression in a ragged array

2011-03-22 Thread Greg Snow
In general when you want to split up your data and do the same thing on each piece then combine the results back together it is good to look at the plyr package. But for this specific case you should look at the lmList function in the nlme package which may do exactly what you want with the

Re: [R] Strange R squared, possible error

2011-03-17 Thread Greg Snow
It is all a matter of what you are comparing too, or what the null model is. For most cases (standard regression) we compare a model with slope and intercept to an intercept only model (looking at the effect of the slope), the intercept only model fits a horizontal line through the mean of the

Re: [R] a question

2011-03-16 Thread Greg Snow
If you do ?Startup then you get the help page that describes all that R does as it starts up and there are a few places in there that it describes where you can put things to be run automatically. I have done this for a doctor before who wanted to show the demonstration I showed him to others,

Re: [R] Gnuplot fit function in R

2011-03-12 Thread Greg Snow
The nls function does nonlinear least squares fits. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Stefan

Re: [R] Drawing a circle on an existing graph.

2011-03-12 Thread Greg Snow
If you are always using asp=1 then you can just do something like: x - rnorm(100, 1, 5) y - rnorm(100, 3, 4) plot( x,y, asp=1) r=2 nseg=360 x.cent - 5 y.cent - 7 xx - x.cent + r*cos( seq(0,2*pi, length.out=nseg) ) yy - y.cent + r*sin( seq(0,2*pi, length.out=nseg) ) lines(xx,yy, col='red')

Re: [R] retrieve x y coordinates of points in current plot

2011-03-05 Thread Greg Snow
It is not completely clear what you are trying to accomplish. Do you want to draw a shape in the plot then identify all the points in that shape? You could use locator (with type='l') to draw a polygon, then there are functions in add on packages (mostly the spatial ones) that will detect

Re: [R] retrieve x y coordinates of points in current plot

2011-03-05 Thread Greg Snow
plotted? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Jannis [mailto:bt_jan...@yahoo.de] Sent: Saturday, March 05, 2011 11:54 AM To: Greg Snow Cc: Dieter Menne; r-help@r-project.org

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Greg Snow
Will failed.3 have each id exactly once? Or could it have multiple lines for a given id? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Greg Snow
Here is one way: tmp1 - data.frame(Species=c('setosa','virginica','versicolor'), + row=c(7,20,18) ) tmp.iris - iris tmp.iris$row - ave(iris$Sepal.Length, iris$Species, FUN=seq_along) out.iris - merge(tmp.iris, tmp1, by=c('Species','row')) out.iris Species row Sepal.Length

Re: [R] Grouping data in ranges in table

2011-03-05 Thread Greg Snow
?cut -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jason Rupert Sent: Saturday, March 05, 2011 3:38 PM To:

Re: [R] Regression with many independent variables

2011-03-04 Thread Greg Snow
[ !is.na(tmp1) ] paste(tmp1, collapse=' + ') -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Matthew Douglas [mailto:matt.dougla...@gmail.com] Sent: Thursday, March 03, 2011 3:43 PM To: Greg Snow

Re: [R] sum of digits or how to slice a number into its digits

2011-03-04 Thread Greg Snow
Here is another way to do it without converting back and forth to character strings: digits - function(x) { if(length(x) 1 ) { lapply(x, digits) } else { n - nchar(x) rev( x %/% 10^seq(0, length.out=n) %% 10 ) } }

Re: [R] R usage survey

2011-03-04 Thread Greg Snow
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Harsh Sent: Thursday, March 03, 2011 3:53 AM To: r-help@r-project.org Subject: [R] R usage survey Hi R users, I request members of the R community to consider filling a

Re: [R] How two compare two matrixes

2011-03-04 Thread Greg Snow
?View -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Alaios Sent: Friday, March 04, 2011 2:49 AM To:

Re: [R] embed latex beamer sans serif default font into R plot

2011-03-04 Thread Greg Snow
Probably the best way to do this is by using the tikzDevice package to create your graphs. This creates TeX commands to create the graph using the same fonts and settings as the rest of the document. The pgfSweave package may also be of interest (it uses tikzDevice to do sweaving). --

Re: [R] R usage survey

2011-03-04 Thread Greg Snow
Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On Behalf Of Hadley Wickham Sent: Friday, March 04, 2011 1:28 PM To: Greg Snow Cc: Harsh; r-help@r-project.org Subject: Re: [R] R usage survey Ok, I am very

Re: [R] Regression with many independent variables

2011-03-03 Thread Greg Snow
...@imail.org 801.408.8111 -Original Message- From: Matthew Douglas [mailto:matt.dougla...@gmail.com] Sent: Thursday, March 03, 2011 2:09 PM To: Greg Snow Cc: r-help@r-project.org Subject: Re: [R] Regression with many independent variables Thanks greg, that formula was exactly

Re: [R] plot, y-axis, uneven scale???

2011-03-03 Thread Greg Snow
You probably want to use the gap.plot function in the plotrix package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On

Re: [R] how many records for suitable regression

2011-03-02 Thread Greg Snow
It really depends on what question you are trying to answer. Things like the relative importance of type I and type II errors could matter a lot. Correlation among the predictors can affect things. What effect size are you looking for and what power do you want? And much more. There is a

Re: [R] bootstrap resampling question

2011-03-01 Thread Greg Snow
Here are a couple of thoughts. If you want to use the boot package then the statistic function you give it just receives the bootstrapped indexes, you could test the indexes for your condition of not more than 5 of each and if it fails return an NA instead of computing the statistic. Then in

Re: [R] Regression with many independent variables

2011-03-01 Thread Greg Snow
(Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Matthew Douglas [mailto:matt.dougla...@gmail.com] Sent: Tuesday, March 01, 2011 1:09 PM To: Greg Snow Cc: r-help@r-project.org Subject: Re: [R] Regression

Re: [R] Regression with many independent variables

2011-02-28 Thread Greg Snow
Don't put the name of the dataset in the formula, use the data argument to lm to provide that. A single period (.) on the right hand side of the formula will represent all the columns in the data set that are not on the left hand side (you can then use - to remove any other columns that you

Re: [R] Interactive/Dynamic plots with R

2011-02-26 Thread Greg Snow
: Saturday, February 26, 2011 1:09 AM To: Greg Snow Cc: r-help@r-project.org Subject: Re: [R] Interactive/Dynamic plots with R Hi Greg Ability to zoom in/out on x/y axis to begin with and then adding/removing data sets. Thanks! -Abhi On Fri, Feb 25, 2011 at 12:52 PM, Greg Snow

Re: [R] Interactive/Dynamic plots with R

2011-02-25 Thread Greg Snow
What types of interaction do you want? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Abhishek Pratap Sent:

Re: [R] Boxplot not doing what I think it should

2011-02-24 Thread Greg Snow
Look at ?quantile, especially the detail section on type and the second reference (and the see also section). There are many different definitions of quantiles/quartiles and different functions use different versions. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

Re: [R] Plot of set

2011-02-21 Thread Greg Snow
Here is a solution using contour: x - y - seq(-1.5,1.5,length=100) z - outer(x, y, function(x,y) x^2+y^2) contour(x,y,z, levels=1) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] assign value to multiple objects with a given ls pattern

2011-02-21 Thread Greg Snow
If instead of having a1, a2, etc. as global variables you put them into a list then this becomes simple. The general rule is that if you ever want to do the same (or similar) think to a set of variable, then they should not have been separate variables, but part of a bigger one. Lists work

Re: [R] Kolmogorov-smirnov test

2011-02-18 Thread Greg Snow
The KS test was designed for continuous variables. The vcd package has tools for exploring categorical variables and distributions. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] removing lower and upper quantiles from an arry

2011-02-17 Thread Greg Snow
In addition to the other answers that you received you can also do: library(TeachingDemos) i[ quantile(i,.25) %% i %% quantile(i,.75) ] This may or may not be more readable than the others. Also note that precomputing both quantiles in one step may be faster than calling quantile twice. You

Re: [R] txtProgressBar examples?

2011-02-15 Thread Greg Snow
When using the windows gui I prefer the winProgressBar to the txtProgressBar. It works basically the same, but does not put any characters into the terminal. (there is also tkProgressBar that works on all platforms, but requires the tcltk package). -- Gregory (Greg) L. Snow Ph.D.

Re: [R] Test for equivalence

2011-02-14 Thread Greg Snow
(Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Albyn Jones [mailto:jo...@reed.edu] Sent: Sunday, February 13, 2011 9:53 PM To: Greg Snow Cc: syrvn; r-help@r-project.org Subject: Re: [R] Test for equivalence

Re: [R] Newb Prediction Question using stepAIC and predict(), is R wrong?

2011-02-14 Thread Greg Snow
There is a section on environments on the help page ?formula, but that may not be completely clear to newer users. Basically the idea is that when you specify a formula, the default place that R will look for the variables in the formula is the data or newdata argument. So if you use those

Re: [R] When is *interactive* data visualization useful to use?

2011-02-14 Thread Greg Snow
There are some interactive graphics tools in the TeachingDemos package (tkBrush allows brushing, tkexamp helps you create your own interactive graphics, etc.). There are also the iplots package, the rgl package (spinning in 3 dimonsions), 'tkrplot' package, the fgui package, the playwith

Re: [R] how to overlay a map of US on image plot

2011-02-14 Thread Greg Snow
You may want to use the ggplot2 package for this (see ?coord_map), it can combine maps and other plots and does a lot of the thinking about scaling and projections for you. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111

Re: [R] xyplot text sizing

2011-02-14 Thread Greg Snow
Modifying the 4th example on the help page for tkexamp (TeachingDemos package) may help with exploring the effects of the different parameters and deciding on a set to use. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111

Re: [R] How can I slightly offset plots?

2011-02-14 Thread Greg Snow
Those types of plots can be very hard to read. A better approach would be to look at the lattice package or faceting in the ggplot2 package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] txtProgressBar examples?

2011-02-14 Thread Greg Snow
Did you try running the examples on the help page ?txtProgressBar ? Basically the txtProgressBar command creates the progress bar, then in the loop the setTxtProgressBar command updates the amount of progress for that bar. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

Re: [R] Test for equivalence

2011-02-12 Thread Greg Snow
Does it make sense for you to combine the 2 data sets and do a 2-way anova with treatment vs. control as one factor and experiment number as the other factor? Then you could test the interaction and treatment number factor to see if they make a difference. -- Gregory (Greg) L. Snow Ph.D.

Re: [R] Calling symbols from dataframe for xyplot

2011-02-11 Thread Greg Snow
The more common way to do this is to use groups, the default is to have a different color for each group, but you can change that using trellis.par.set: tmp - trellis.par.get() tmp$superpose.symbol$pch = 0:10 trellis.par.set(tmp) xyplot(Sepal.Width ~ Petal.Width, data=iris, groups=Species,

Re: [R] How to compute yaxp and usr without plotting ?

2011-02-11 Thread Greg Snow
The usr parameter is either ylim or ylim plus 4 percent on either side (see yaxs/xaxs), see the pretty function for possible ways to get the yaxp information. Note that strwidth is based on the current coordinate system and will not give you the proper values unless the plot region has already

Re: [R] : package to draw

2011-02-10 Thread Greg Snow
You could use the floating.pie function in the plotrix package, but even the author of that function/package has stated in the past that pie charts are not the best tool. Also look at the symbols function for some alternatives, I would use the thermometers (and if that does not give enough

Re: [R] newbie Question on Generic and Method

2011-02-09 Thread Greg Snow
The generic is what the user calls, the method is what the generic calls. For example, the summary function is a generic function, when you issue a command like summary(x) then the generic function looks at what type of object x is and calls the appropriate method which might be the summary.lm

Re: [R] Removing Outliers Function

2011-02-09 Thread Greg Snow
For your number 2, look at the outliers data set in the TeachingDemos package and run the 1st set of examples, yes it uses a different rule than you use, but still a common one. Think about what is happening in the example, doesn't that make you a little nervous about methods that

Re: [R] circular

2011-02-08 Thread Greg Snow
You may want to look at the density.circular and plot.density.circular functions in the circular package. The pie slice idea is a bit tricky because the human eye tends to compare the areas of the slices rather than the distance from the center (and the area will be proportional to the

Re: [R] Perform one-way ANOVA using standard deviation and mean

2011-02-08 Thread Greg Snow
Another approach (still using the theory of sufficient statistics) is to generate data from a normal distribution that matches exactly the sizes, means, and standard deviations that you have, then analyze the simulated data. The mvrnorm function in the MASS package can generate data with a

Re: [R] Stopping between multiple graphs

2011-02-08 Thread Greg Snow
Look at ?par and specifically the ask option. Or, you can use the pdf function to send a set of graphs directly to a pdf file, then open the pdf file and step through (and go back if you want) the graphs. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] Proportions comparison

2011-02-08 Thread Greg Snow
How do you anticipate the number of doctors affecting the proportions? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On

Re: [R] please hep in uniform distribution

2011-02-08 Thread Greg Snow
You are comparing B[1] to A[1]^2, then B[2] to A[2]^2 etc. so for the AB pairs you are doing the comparison. If that is what you want, then it is fine. But if you want to compare the 1st B to all the A's, then the 2nd B to all the A's, etc. Then it does not do this (but the expand.grid

Re: [R] Use glm coefficients for other datasets

2011-02-08 Thread Greg Snow
What happens if you use the newdata argument name instead of data? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf

Re: [R] Removing X and Y labels in graph error

2011-02-08 Thread Greg Snow
If you want to expand the area that the graph takes up (using the space that the labels would have been in) look at the mar part of ?par. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] Plot using treatment letter as points

2011-02-08 Thread Greg Snow
xyplot is a lattice plotting command, text is a base plotting command. The 2 types don't play well together without extra work. The base command plot with text is probably the easiest, or you can just use plot and pch: with(iris, plot(Sepal.Width, Sepal.Length, pch=c('s','e','i')[Species] )

Re: [R] spline interpolation

2011-02-05 Thread Greg Snow
Also ?splinefun (like approxfun but using splines instead of lines). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On

Re: [R] Lightweight store plots as images.

2011-02-05 Thread Greg Snow
I would use a pdf file, see ?pdf for examples. This plots a bunch of plots to a single file. You can also use tools like png (see ?png for examples) which will create 1 file per plot. You can either specify a name each time, or set a name pattern and have it fill in automatically. Either

Re: [R] A list within a list?

2011-02-05 Thread Greg Snow
How are your lists being created? You can add each list to a mega list in a for loop, or use lapply to run a function multiple times which outputs a list each time and these will automatically be put together into a mega list. If these don't work for you then tell us more about how you are

Re: [R] Finding non-normal distributions per row of data frame?

2011-02-04 Thread Greg Snow
I get a different set of errors than you do (what version of R are you using?). Patrizio showed one way to do what you want. But, what is it that you are really trying to accomplish? What do you think the result of 20,000 normality tests (each of which may not be answering the real question

Re: [R] recode according to specific sequence of characters within a string variable

2011-02-04 Thread Greg Snow
So you want to combine multiple columns back into a single column with the strings pasted together? If that is correct then look at the paste and sprintf functions (use one or the other, not both). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] recode according to specific sequence of characters within a string variable

2011-02-04 Thread Greg Snow
You can do this with regular expressions, since you want to extract specific values from the string I would suggest learning about the gsubfn package, it is a bit easier with gsubfn than with the other matching tools. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

<    3   4   5   6   7   8   9   10   11   12   >