Re: [R] specify data frame by name

2010-10-15 Thread Greg Snow
Also look at the get function, it may be a bit more straight forward (and safer if there is any risk of someone specifying 'rm(ls())' as a data frame name). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original

Re: [R] Recovering x/y coordinates from a scatterplot image

2010-10-16 Thread Greg Snow
You can do this by reading in the image and plotting it, then use the updateusr function from the TeachingDemos package to set the user coordinates to match the image (use locator to find the current values of some points). Then you can just use the locator function to get the coordinates of

Re: [R] Variable name as string

2010-10-16 Thread Greg Snow
You can get the name of var by doing coeffname - deparse(substitute(var)) Is that what you wanted? -- 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] Sine function fitting

2010-10-18 Thread Greg Snow
If you know the period of the sine that you want to fit (just fitting the amplitude, phase shift, and offset) and are willing to assume normal errors (or at least normal enough for the CLT) then you can just use the lm function. If you need to find the period as well (but still willing to

Re: [R] points( .... pch=2) substitue pch with image

2010-10-19 Thread Greg Snow
Look at my.symbols and ms.image 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-boun...@r- project.org] On Behalf Of

Re: [R] Tif image to 8bit colour matrix.

2010-10-19 Thread Greg Snow
Look at the EBImage package from bioconductor. -- 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-boun...@r- project.org] On Behalf Of Roger Gill

Re: [R] S: appropriate significance tests

2010-10-20 Thread Greg Snow
It is not completely clear what question you are trying to answer or what you are trying to accomplish. But here are some additional questions that may help: What tests would you use if you could use the original data? What assumptions are you willing to make about the data and/or statistics?

Re: [R] Function execution on package load?

2010-10-20 Thread Greg Snow
?.First.lib -- 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-boun...@r- project.org] On Behalf Of Johannes Graumann Sent: Wednesday, October 20,

Re: [R] calculate power of test

2010-10-20 Thread Greg Snow
I generally use simulation to calculate power: library(MASS) out1 - replicate(1, {tmp - mvrnorm(100, mu=c(0,0), Sigma=matrix( c(1,.2,.2,1), 2 ) ); cor.test( tmp[,1], tmp[,2] )$p.value } ) mean( out1 = 0.05 ) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

Re: [R] Display list redraw incomplete when exporting plots

2010-10-22 Thread Greg Snow
Can you show us the code that generated the errors? Best if you can provide reproducible code (stuff that we can just cut and paste and it runs, not depending on data that we do not have, you can generate random data, use built in datasets, or use dput with your data). -- Gregory (Greg) L.

Re: [R] Zoom in in a plot

2010-10-26 Thread Greg Snow
For a quick exploration of the plot you can use the zoomplot function in the TeachingDemos package. But for production graphs it is better to explicitly set the xlim and ylim parameters in creating the plot up front. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain

Re: [R] connecting points into a smooth curve

2010-11-02 Thread Greg Snow
In addition to the other responses you have received, the xspline function may also be of use. -- 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] Visualisation of data structures

2010-11-05 Thread Greg Snow
There is the TkListView function in the TeachingDemos package for looking at list structures. It gives you a view of the list structure with nested elements available to be expanded by clicking on the little plus sign. You can view or run code on the selected piece, which could help create

Re: [R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread Greg Snow
Look at power.examp in the TeachingDemos package. If that plot is not good enough, you can steal the code and modify to your specifications. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Greg Snow
If you are willing to shift the c vector by 1 and have 1 (the initial value) as the start of c, then you can just do: cumsum( cc * b^( (n-1):0 ) ) / b^( (n-1):0 ) to compare: cc - c(1, rnorm(999) ) b - 0.5 n - length(cc) a1 - numeric(100) a1[1] - 1 system.time(for(i in 2:n ) { a1[i]

Re: [R] How to eliminate this for loop ?

2010-11-09 Thread Greg Snow
[mailto:r-help-boun...@r- project.org] On Behalf Of Greg Snow Sent: Monday, November 08, 2010 1:15 PM To: PLucas; r-help@r-project.org Subject: Re: [R] How to eliminate this for loop ? If you are willing to shift the c vector by 1 and have 1 (the initial value) as the start of c, then you can

Re: [R] How to eliminate this for loop ?

2010-11-09 Thread Greg Snow
Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Greg Snow Sent: Tuesday, November 09, 2010 8:31 AM To: Greg Snow; PLucas; r-help@r-project.org Subject: Re: [R] How to eliminate this for loop

Re: [R] help to add a new column filled with value 1

2010-11-09 Thread Greg Snow
Here are 2 possibilities: cbind( iris[,1, drop=FALSE], 1, iris[,2:5] ) cbind( iris, 1) [ ,c(1,6,2:5) ] -- 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] Calculate Mean from List

2010-11-09 Thread Greg Snow
You could use the Reduce function to get the sum of the matrices, then if there are no missing vales just divide by the number of matrices. If there are missing values then you would probably need to use Reduce again to count the number of non-missing values. Since all the matrices are the

Re: [R] Centring titles for pairs of plots --- a solution.

2010-11-09 Thread Greg Snow
Also look at the grconvertX function for a different way of finding the coordinates to plot at. -- 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] p-value from regsubsets

2010-11-10 Thread Greg Snow
What hypothesis do you expect the p-values to be testing? What you would get from regsubsets is unlikely to test any hypothesis of interest. If you really feel the need for p-values then the safest approach is probably the function SnowsCorrectlySizedButOtherwiseUselessTestOfAnything in the

Re: [R] Kolmogorov Smirnov Test

2010-11-10 Thread Greg Snow
The way you are running the test the null hypothesis is that the data comes from a normal distribution with mean=0 and standard deviation = 1. If your minimum data value is 0, then it seems very unlikely that the mean is 0. So the test is being strongly influenced by the mean and standard

Re: [R] Is there effective way using R to select variables subset!

2010-11-10 Thread Greg Snow
Check out the rms package, especially the validate function. -- 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-boun...@r- project.org] On Behalf Of

Re: [R] Kolmogorov Smirnov Test

2010-11-11 Thread Greg Snow
necessary, so is it incorrect to have the same standard deviation too? I need to go back and read on the K-S test to see what the appropriate constraints are before bothering anyone for more help. Sorry, I thought I had it. Thanks again, kbrownk On Nov 11, 12:40 am, Greg Snow greg.s

Re: [R] Time Delay / Wait

2010-11-12 Thread Greg Snow
In addition to Michael's answer, look at the ?par help page and look at the ask argument, you can use this to have the graphics device wait for you to click before starting a new plot. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org

Re: [R] Merge postscript files into ps/pdf

2010-11-12 Thread Greg Snow
The best approach if creating all the files using R is to change how you create the graphs so that they all go to one file to begin with (as mentioned by Joshua), but if some of the files are created differently (rgl, external programs), then this is not an option. One external program that

Re: [R] Need help with pointLabels()

2010-11-15 Thread Greg Snow
What package is pointLabel (or is it pointLabels) in? giving a reproducible example includes stating packages other than the standard ones. What you are trying to do is not simple for general cases, some tools work better on some datasets, but others work better on other datasets. Some other

Re: [R] Defining functions inside loops

2010-11-15 Thread Greg Snow
This is a side effect of the lazy evaluation done in functions. Look at the help page for the force function for more details and how to force evaluation and solve your problem. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111

Re: [R] How to plot effect of x1 while controlling for x2

2010-11-15 Thread Greg Snow
Look at Predict.Plot (and TkPredict) from 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-boun...@r- project.org] On

Re: [R] plot vs print ??

2010-11-17 Thread Greg Snow
Well, assuming this refers to the histogram function in the lattice package, looking at the code for print.trellis shows that the default behavior is to call plot.trellis with the same arguments. So unless you change the default behavior, there really is no difference between printing and

Re: [R] aspect ratio 1 and blank space

2010-11-18 Thread Greg Snow
Look at the squishplot function in the TeachingDemos package, it may do what you want, or if not quite then you could perhaps tweak the code to include the values you want and create the correct aspect ratio. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] how exactly does 'identify' work?

2010-11-18 Thread Greg Snow
I think that your problem comes from a misunderstanding. The general rule is that you give the plot command 2 vectors, x and y (though you can give it the vectors separately, or together in a list or matrix). If you give plot only a single vector then it will use this as the y vector and use

Re: [R] how exactly does 'identify' work?

2010-11-18 Thread Greg Snow
Did you read the help page for qqnorm? The return value has the x and y coordinates used, you can just do something like: tmp - qqnorm( resid(test.lm) ) identify(tmp, , names(resid(test.lm)) ) Or the plot.lm function has an argument id.n that automatically labels the n most extreme values:

Re: [R] how exactly does 'identify' work?

2010-11-18 Thread Greg Snow
-help-boun...@r- project.org] On Behalf Of Greg Snow Sent: Thursday, November 18, 2010 1:11 PM To: casperyc; r-help@r-project.org Subject: Re: [R] how exactly does 'identify' work? Did you read the help page for qqnorm? The return value has the x and y coordinates used, you can just do

Re: [R] Bold plot axis

2010-11-19 Thread Greg Snow
Often when things look to small/thin it is because the plot is being created at too large a size, then shrunk. How are you creating the graph? How are you transferring it? Try creating the graph at the exact size that it will be when used in the powerpoint, then without needing to resize

Re: [R] How to produce a graph of glms in R?

2010-11-22 Thread Greg Snow
Look at Predict.Plot (and possibly TkPredict) 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-boun...@r- project.org]

Re: [R] overlay histograms on map at map coordinates

2010-11-23 Thread Greg Snow
Look at the subplot 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-boun...@r- project.org] On Behalf Of

Re: [R] how to add frequencies to barplot

2010-11-23 Thread Greg Snow
I would suggest reading the discussion (all the posts) starting at: http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html This gives reasons for not doing what you are asking along with some alternatives. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] save a regression model that can be used later

2010-11-23 Thread Greg Snow
One possibility for what is happening is that when you load the object it does not automatically load the package as well, so you get an error when working with the object. Try loading lme4 package in a new session, then load the saved object and see if things work for you. -- Gregory (Greg)

Re: [R] how do remove those predictor which have p value greater than 0.05 in GLM?

2010-11-23 Thread Greg Snow
What Frank was trying to tell you is that the p-values don't have much meaning if you do stepwise regression (sometimes they are worse than useless). The p-values are computed based on certain assumptions, once you remove a variable because it is Not Significant, then recompute, those

Re: [R] Sampling from multi-dimensional kernel density estimation

2010-11-23 Thread Greg Snow
Generating new data from a kernel density estimate is equivalent to choosing a point from your data at random, then generating a point from your kernel centered at the chosen point. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org

Re: [R] Getting user input without hitting enter

2010-11-24 Thread Greg Snow
This is a user interface issue. The standard command line user interfaces all wait for the user to hit enter before sending the information to the parser, so this cannot be done using the standard command line interface. You could rewrite the source code, but that is probably overkill. The

Re: [R] Par() Variables, Timing, and Resizing

2010-11-24 Thread Greg Snow
I would suggest using the layout function instead of the mfcol and pin with par. The layout function gives you more control of the size of areas to be plotted to. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original

Re: [R] What is the degrees of freedom in an nlme model

2010-07-13 Thread Greg Snow
If the curves are sufficiently close to sine (cosine) curves and you know the period, then this can be restructured as a linear model and you can avoid all the complexities that come with non-linear models. Further, from your description, it does not sound like you really gain much from using

Re: [R] How can i draw a graph with high and low data points

2010-07-13 Thread Greg Snow
There are several functions in several packages for plotting intervals that will give you plots much better than the excel one. The RSiteSearch function or the sos package may help you find those. But it is also easy to create such plots using just a few lines of R code and base graphics.

Re: [R] StartsWith over vector of Strings?

2010-07-13 Thread Greg Snow
content[na.omit(pmatch(searchset, content,,TRUE))] -- 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-boun...@r- project.org] On Behalf Of Ralf B

Re: [R] Generate groups with random size but given total sample size

2010-07-13 Thread Greg Snow
For one definition of random: ss - rexp(100) ss - ss/sum(ss) ss - 5 + round( ss*9500 ) cnt - 0 while( ( d - sum(ss) - 1 ) != 0 ) { tmpid - sample.int(100,1) ss[tmpid] - ss[tmpid] - d ss[ ss 500 ] - 500 ss[ ss 5 ] - 5 cnt - cnt + 1

Re: [R] StartsWith over vector of Strings?

2010-07-13 Thread Greg Snow
- From: Ralf B [mailto:ralf.bie...@gmail.com] Sent: Tuesday, July 13, 2010 11:57 AM To: Greg Snow Cc: r-help@r-project.org Subject: Re: [R] StartsWith over vector of Strings? When running the combined code with your suggested line: content - data.frame(urls=c( http://www.google.com

Re: [R] create variables with indexes

2010-07-13 Thread Greg Snow
It looks like you want to use a matrix, then you can do proper indexing. Creating the names will just lead to unnecessary complexity and confusion. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message-

Re: [R] Constrain density to 0 at 0?

2010-07-24 Thread Greg Snow
Look at the logspline package. This is a different approach to density estimation from the kernel densities used by 'density', but does allow you to set fixed boundaries. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-24 Thread Greg Snow
You may want to look at the biglm package as another way to regression models on very large data sets. -- 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] Concatenate a mix of numbers and letters to create a vector name

2010-07-27 Thread Greg Snow
This is a frequently asked/answered question (7.21 in the FAQ). What searching did you do and why did it not find this FAQ or previous discussion of it? How could the documentation/search/etc. be improved so that you (and the next n people with this question) will find the answer easier? The

Re: [R] hatching posibility in Panel.Polygon

2010-07-27 Thread Greg Snow
Hopefully the right now will be a forever. The fact that trellis graphics do not support hatching is a conscious decision or feature, not a bug or missing feature to be corrected some day (at least I for one will be disappointed if Deepayan (or someone else) gives in and implements it). Have

Re: [R] how to generate a random data from a empirical distribition

2010-07-27 Thread Greg Snow
Another option for fitting a smooth distribution to data (and generating future observations from the smooth distribution) is to use the logspline package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original

Re: [R] Fwd: Questions about templates for R

2010-07-27 Thread Greg Snow
Look at the HSAUR package (and the book that it goes with). This may give you (your students) enough to start on several topics. If you use these examples then you should probably include the book as at least an optional text for the class. -- Gregory (Greg) L. Snow Ph.D. Statistical Data

Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Greg Snow
It is probably easier to do this without eval and parse (see fortune(106)). Something like: val - get(dataname)[[v1]] hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] how to generate a random data from a empirical distribition

2010-07-27 Thread Greg Snow
Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Frank Harrell [mailto:f.harr...@vanderbilt.edu] Sent: Tuesday, July 27, 2010 4:54 PM To: Greg Snow Cc: xin wei; r-help@r-project.org Subject: Re: [R] how to generate a random data from a empirical distribition

Re: [R] Add an arrow to a plot

2010-07-27 Thread Greg Snow
In addition to the arrows function, look at the my.symbols and ms.arrows functions in the TeachingDemos package, this is a wrapper around the arrows function, but may be a more natural interface for what you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] hatching posibility in Panel.Polygon

2010-07-28 Thread Greg Snow
Tufte discusses hash lines in his book The Visual Display of Quantitative Information and does a better job of it than I can. The short version is that the hashing can actually produce optical illusion effects that distort the information. (and often don't copy well either). Printing and

Re: [R] locator function and connecting segment

2010-07-29 Thread Greg Snow
Do you mean like: plot(1:10) locator(2, type='l') -- 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-boun...@r- project.org] On Behalf Of Erin

Re: [R] adding new devices and plots

2010-07-29 Thread Greg Snow
It is possible that the plot function starts to plot before the new device is fully in place, you could try sleeping for a second or 2 between the call to dev.new and the call to plot. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org

Re: [R] Fwd: Using R for Multiple Regression

2010-08-03 Thread Greg Snow
There are an infinite number of solutions for your example, so I hope you really don't want to see all of them. In theory you could work up some code to start showing them to you, but the sun will go nova and atomize you and your computer before it shows all of them. Expressing the infinite

Re: [R] question!!!!

2010-08-04 Thread Greg Snow
?scale -- 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-boun...@r- project.org] On Behalf Of leepama Sent: Tuesday, August 03, 2010 10:55 PM To:

Re: [R] does R have a command the same with Stata's loop command: ` '

2010-08-04 Thread Greg Snow
Do ?'for' to learn about for loops. Look at FAQ 7.21 for the other part of the question (the most important part of the answer is the end where it tells you to use lists instead like Patrick suggests). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] KS Test question (2)

2010-08-05 Thread Greg Snow
The warning (with an error you would not see any results) means that there are ties in your data, the theory behind the ks test says that the probability of seeing ties is 0, so your data and the theory do not match, therefore the p-value is suspect (though an ok approximation for some uses).

Re: [R] Kolmogorov-Smirnov test, which one to use?

2010-08-05 Thread Greg Snow
It is not clear what question you are trying to answer. Perhaps if you can give us an explanation of your overall goal then we can be more helpful. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message-

Re: [R] Multiply each depth level of an array with another vector element

2010-08-06 Thread Greg Snow
?sweep -- 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-boun...@r- project.org] On Behalf Of Maurits Aben Sent: Thursday, August 05, 2010 2:00 PM

Re: [R] eval-parse and lme in a loop

2010-08-06 Thread Greg Snow
fortune(106) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) Here is one approach that seems to be working: for (meanCol in paste(Mean_, 1:3, sep=)) { cat('\n##',meanCol,'\n\n') f - formula( paste(

Re: [R] plot the dependent variable against one of the predictors with other predictors as constant

2010-08-09 Thread Greg Snow
Look at the TkPredict and Predict.Plot functions in the TeachingDemos package as a couple of options. -- 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] Pie Chart in map

2010-08-09 Thread Greg Snow
Look at the my.symbols and subplot functions in the TeachingDemos package, one of those may work for you. Note however that the author of those functions is one of the advocates against the use of pie charts and if there were a free (as in speech) license that would allow for excluding any use

Re: [R] Function to Define a Function

2010-08-10 Thread Greg Snow
What if you change your function to: mdlChooser - function(type=c(one,two)) { type - match.arg(type) switch(type, one={ function(x,N0,r) N0*exp(x*r) }, two={ function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) }, ) } Does that work for you? -- Gregory (Greg) L. Snow Ph.D. Statistical

Re: [R] Concatenate a mix of numbers and letters to create a vector name

2010-08-10 Thread Greg Snow
this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Panos Hadjinicolaou [mailto:p.hadjinicol...@cyi.ac.cy] Sent: Tuesday, August 10, 2010 6:07 AM To: Greg Snow; r-help@r-project.org

Re: [R] p-values with pvclust

2010-08-10 Thread Greg Snow
I don't know much about pvclust itself, but you might consider the technique in this paper: Buja, A., Cook, D. Hofmann, H., Lawrence, M. Lee, E.-K., Swayne, D.F and Wickham, H. (2009) Statistical Inference for exploratory data analysis and model diagnostics Phil. Trans. R. Soc. A

Re: [R] Running something without a loop when the result from the previous iteration is require for the current iteration

2010-08-11 Thread Greg Snow
What is wrong with using a loop? It used to be that loops were much slower than some of the alternatives, but now days a well crafted loop runs almost as fast (sometime faster) than the apply functions. So if the loop is working for you, use it and don't worry about it (though there may be

Re: [R] Adding points sequentially to multiple graphs in one window (device)

2010-08-11 Thread Greg Snow
The simplest thing to do is just recreate the plot(s) from scratch at each iteration with all the accumulated data. Most graphics devices are fast enough now that you will not notice the redraw. If you really just want to add to the plots, you can save and restore the graphics parameters,

Re: [R] storing the results of an apply call

2010-08-12 Thread Greg Snow
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Joshua Wiley Sent: Wednesday, August 11, 2010 6:31 PM To: Lorenzo Cattarino Cc: r-help@r-project.org Subject: Re: [R] storing the results of an apply call What follows is

Re: [R] Scatterplot - Overlap Frequency

2010-08-12 Thread Greg Snow
If you want a grid of hexagons, look at the examples in the my.symbols function (TeachingDemos package), one of those gives a way to create the grid of hexagons (not as efficient as the hexbin package, but allows you to set your own colors). For choosing colors you may want to look at the

Re: [R] storing the results of an apply call

2010-08-12 Thread Greg Snow
-Original Message- From: Marc Schwartz [mailto:marc_schwa...@me.com] Sent: Thursday, August 12, 2010 3:32 PM To: Greg Snow; Joshua Wiley Cc: r-help@r-project.org Forum Subject: Re: [R] storing the results of an apply call P.S. Pardon me while I go visit with the Emacs

Re: [R] storing the results of an apply call

2010-08-12 Thread Greg Snow
-Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, August 12, 2010 3:13 PM To: Greg Snow Cc: Joshua Wiley; r-help@r-project.org Subject: Re: [R] storing the results of an apply call On Aug 12, 2010, at 5:07 PM, Greg Snow wrote: [1

Re: [R] Games

2010-08-13 Thread Greg Snow
How about: tmp - expand.grid(one = 1:11, two = 1:11) tmp$week - ( ( tmp$one + tmp$two ) %% 11 ) + 1 # reformat for simplicity tmp2 - tmp[ order(tmp$week), ] tmp3 - tmp2[ tmp2$one tmp2$two , ] ### do some checks to make sure everyone plays everyone ###exactly once and each team plays at

Re: [R] Dealing with data

2010-08-13 Thread Greg Snow
R/S does all of that automatically for you, you do not need to manually create the indicator variables. If you do something like: fit - lm( Sepal.Width ~ Species, data=iris, x=TRUE) Then look at the matrix actually used: fit$x Or the output: summary(fit) You will see that Species was

Re: [R] How to compare the effect of a variable across regression models?

2010-08-13 Thread Greg Snow
If you just want to visualize the effect on one variable on the response from some different models then you might try Predict.Plot from the TeachingDemos package. It takes a little tweaking to get it to work with cph objects, but here is a basic example (partly stolen from the help page for

Re: [R] subsetting data points within confidence limit

2010-08-13 Thread Greg Snow
Why would you want to do this? Confidence intervals tell you about the uncertainty of the mean of y give x, not the individual data points. It may make more sense to use prediction intervals that tell you about individuals rather than means, but that still means throwing away alpha% of

Re: [R] Dealing with data

2010-08-13 Thread Greg Snow
you suggest I read? Thanks. data(InsectSprays) lm(InsectSprays$count ~ 0 + InsectSprays$spray) On Aug 13, 2010, at 10:34 AM, Greg Snow wrote: R/S does all of that automatically for you, you do not need to manually create the indicator variables. If you do something like: fit - lm

Re: [R] detecting a key press

2010-08-14 Thread Greg Snow
The playSudoku function in the Sudoku package reacts to keypresses using windows or Tk, you can use that as an example. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] Missing values in function calls

2010-08-18 Thread Greg Snow
?missing -- 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-boun...@r- project.org] On Behalf Of vo...@cbox.cz Sent: Tuesday, August 17, 2010 6:22 AM

Re: [R] replacing values in a vector

2010-08-18 Thread Greg Snow
What do you plan to do with those vectors? Creating a set of vectors and 'asign'ing them as global variables will likely make future tasks harder than they need to be. In the long run it will probably work better for you to either keep them as a matrix (and just access the row/column you

Re: [R] Linear regression equation and coefficient matrix

2010-08-18 Thread Greg Snow
Well you already have the correlation matrix, so you can just work from there. One of the profound equations in statistics is that r^2=r^2, meaning that to get r2 (as you call it, assuming you mean the coefficient of determination) just square the elements of the correlation matrix. To get

Re: [R] How to measure correlations in terms of distance and draw them on a 2-dimmentional plot?

2010-08-18 Thread Greg Snow
Do a search for multidimensional scaling and that should give some ideas (use 1-cor or something like that as the distance measure). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message-

Re: [R] ifelse command

2010-08-19 Thread Greg Snow
It would help us help you if you could give a description of what your ultimate goal is here. Is it to simulate the dice? Then you may want to just use the dice function in the TeachingDemos package (or you can animate the rolling with plot.rgl.die and roll.rgl.die in the same package). Or

Re: [R] Linear regression equation and coefficient matrix

2010-08-19 Thread Greg Snow
Here is a quick example: c1 - cor(iris[,-5]) s1 - sqrt(diag(var(iris[,-5]))) betas - diag( s1 ) %*% c1 %*% diag( 1/s1 ) # now compare: coef( lm( Sepal.Length ~ Sepal.Width, data=iris ) )[2] betas[1,2] But if you cannot work that out on your own, then you really should review linear algebra

Re: [R] R reports

2010-08-19 Thread Greg Snow
Your question brings up a bit of a philosophical issue (or possibly economic theory). The idea is the contrast between specialization and generalization. A purely specialized program will only do one thing (but hopefully do that one thing well), the ultimate generalized program will do

Re: [R] Trimmed Sample

2010-08-19 Thread Greg Snow
You can look at the code for mean.default and see how it does the trimming, then you can use that to create your own trimmed version to pass to other functions. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original

Re: [R] Automated plot and linear regression line/data

2010-08-19 Thread Greg Snow
?pairs ?lattice::splom ?lattice::panel.xyplot pairs( state.x77, panel=function(x,y){ points(x,y) abline(lm(y~x), col='red') }) library(lattice) splom( ~state.x77, type=c('p','r') ) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare

Re: [R] Aspect Ratio

2010-08-23 Thread Greg Snow
A couple of additional examples of when asp is important to use: The command abline(0,1) adds a line to the current plot, this line is often referred to as the 45 degree line, but the angle with the axes is only 45 degrees when asp==1, setting asp=1 will enforce this. There are multiple

Re: [R] Regex exercise

2010-08-23 Thread Greg Snow
How about: x - 1 2 -5, 3- 6 4 8 5-7 10; x library(gsubfn) strapply( x, '(([0-9]+) *- *([0-9]+))|([0-9]+)', function(one,two,three,four) { if( nchar(four) 0 ) return(as.numeric(four) ) return( seq( from=as.numeric(two), to=as.numeric(three) ) )

Re: [R] graphing plots of plots

2010-08-24 Thread Greg Snow
In addition to the other suggestions you may also want to look at the subplot function in the TeachingDemos package (the version in Hmisc is a copy of a prior version of this one) as well as the my.symbols or panel.my.symbols functions in the same package. -- Gregory (Greg) L. Snow Ph.D.

Re: [R] How to obtain seed after generating random number?

2010-08-25 Thread Greg Snow
If you find yourself doing things like this often, but don't want to explicitly set the seed, or save seeds before simulating, then you can run the following code (or put it into .Rprofile or similar): .Last.Random.seed - .Random.seed addTaskCallback( function(expr, val, ok, visible){

Re: [R] output values from within a function

2010-08-25 Thread Greg Snow
Put the line: cat(z1,'\n') in your function. You may also want to put the flush.console() command right after that. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

Re: [R] Removing inter-bar spaces in barchart

2010-08-25 Thread Greg Snow
Using the barplot function in base graphics you just set space=0, but that function does not have a box.ratio argument which would imply that you are using something else. If you let us know which function (and which package it is in) then it is easier (possible) for us to help you, even

  1   2   3   4   5   6   7   8   9   10   >