Re: [R] Multiple left hand side variables in a formula

2013-03-02 Thread Achim Zeileis
On Fri, 1 Mar 2013, Frank Harrell wrote: Thank you Bill. A temporary re-arrangement of the formula will allow me to do the usual subset= na.action= processing afterwards. Nice idea. I don't need the dot notation very often for this application. That's what the Formula package provides. It

[R] replace zeros for NA in a column based on values of another column

2013-03-02 Thread Camilo Mora
Hi everyone, Imagine that I have a data frame with four columns: data- a b c d 0 1 1 0 1 1 1 1 1 0 0 1 I want to replace the zeros in columns a:b for NA only for the rows in which column d are zero. So a b c

Re: [R] using reserved words in R, and reuse variable names in different functions

2013-03-02 Thread Duncan Murdoch
On 13-03-01 8:35 PM, C W wrote: Thanks, everyone, I will definitely avoid it. Is there any tips on naming variables? I've seen the Google R style guider and Hadley R style guide. Name them in ways that are meaningful to you. R standard function names are famous for not following any naming

Re: [R] replace zeros for NA in a column based on values of another column

2013-03-02 Thread Anthony Damico
you want to replace all rows where the 4th column is zero.. (data[ , 4 ] == 0) and you want to perform that replacement in the first column.. so try data[ data[ , 4 ] == 0 , 1 ] - NA On Sat, Mar 2, 2013 at 5:26 AM, Camilo Mora cm...@dal.ca wrote: Hi everyone, Imagine that I have a data

Re: [R] replace zeros for NA in a column based on values of another column

2013-03-02 Thread Rui Barradas
Hello, Try # for columns a.b it's 1:2, not 1:3 data[data[,4] == 0, 1:3] - NA # columns a, b and c Hope this helps, Rui Barradas Em 02-03-2013 10:26, Camilo Mora escreveu: Hi everyone, Imagine that I have a data frame with four columns: data- a b c d 0 1 1

Re: [R] Multiple left hand side variables in a formula

2013-03-02 Thread Frank Harrell
Achim this is perfect. I had not seen Formula before. Thanks for writing it! Frank Achim Zeileis-4 wrote On Fri, 1 Mar 2013, Frank Harrell wrote: Thank you Bill. A temporary re-arrangement of the formula will allow me to do the usual subset= na.action= processing afterwards. Nice idea.

Re: [R] Multiple left hand side variables in a formula

2013-03-02 Thread Frank Harrell
Hi Gabor, This is not for a regression function but for a major update I'm working on for the summary.formula function in the Hmisc package. So I need to handle several data types in the formula. Thanks Frank Gabor Grothendieck wrote Gabor Grothendieck wrote On Fri, Mar 1, 2013 at 7:16 PM,

Re: [R] Dealing with parentheses within variable names

2013-03-02 Thread Duncan Murdoch
On 13-03-01 12:57 PM, Duncan Murdoch wrote: On 01/03/2013 11:20 AM, William Dunlap wrote: A core R function that fails with odd names is reformulate(): reformulate(c(P/E, % Growth), response=+-) Error in parse(text = termtext) : text:1:16: unexpected input 1: response ~ P/E+%

[R] How to start console output with a comment sign (as in knitr)

2013-03-02 Thread Marcus Kriele
Dear all, knitr writes a comment sign in front of each line of console output. This extremely useful, especially for beginners who are starting to write scripts. One could just compose their script in the console (getting immediate output) and then copy the whole chunk into their .r-file. I

Re: [R] replace zeros for NA in a column based on values of another column

2013-03-02 Thread arun
HI, Not sure I understand it correctly, data1-read.table(text=  a  b  c  d  0  1  1  0  1  1  1  1  1  0  0  1 ,sep=,header=TRUE) data2- data1 data3- data1 If i follow this logic for the 1st and 2nd columns,  data1[ data1[ , 4 ] == 0 , 1 ] - NA  

[R] Expressions in lattice conditional variables

2013-03-02 Thread Frank Harrell
I would like to have a lattice conditioning ( | var ) variable have expression() as values because I want panel labels to be able to use plotmath notation for subscripts, etc. lattice barks at this. Does anyone know of a trick workaround? An attempted example program is below. Thanks -Frank

Re: [R] Expressions in lattice conditional variables

2013-03-02 Thread Frank Harrell
Whoops - these 2 lines should have been omitted from the program: n - sprintf('%s (n%s=%g, n%s=%g)', v, nam[1],n[1], nam[2],n[2]) vn[var == v] - n Frank Harrell wrote I would like to have a lattice conditioning ( | var ) variable have expression() as values because I want panel labels

Re: [R] replace zeros for NA in a column based on values of another column

2013-03-02 Thread Rui Barradas
Hello, Arun has a point, I forgot to check the element to be replaced for a zero. The following code will do that. dat - read.table(text = a b c d 0 1 1 0 1 1 1 1 1 0 0 1 , header = TRUE) dat - data.matrix(dat) str(dat)

Re: [R] How to start console output with a comment sign (as in knitr)

2013-03-02 Thread Bert Gunter
?options Change the prompt option: options(prompt = # ) ## is I think what you want. -- Bert On Sat, Mar 2, 2013 at 5:35 AM, Marcus Kriele mkri...@me.com wrote: Dear all, knitr writes a comment sign in front of each line of console output. This extremely useful, especially for beginners

[R] print method like print.anova()

2013-03-02 Thread Michael Friendly
I have a print method for a set of statistical tests, vcdExtra::CMHtest, for which I'd like to have more sensible printing of pvalues, as in print.anova(). [Testing this requires the latest version of vcdExtra, from R-Forge **|install.packages(vcdExtra, repos=http://R-Forge.R-project.org;)|** ]

Re: [R] How to start console output with a comment sign (as in knitr)

2013-03-02 Thread Greg Snow
Try the following to see if it does what you want: ## init con - textConnection(output, w) options(echo=FALSE) sink(con) addTaskCallback( function(expr, out, err, vis) { sink() close(con) if(vis) { cat(paste(#, output, collapse=\n), \n) } con - textConnection(output, w) sink(con) TRUE }) 3+4

Re: [R] print method like print.anova()

2013-03-02 Thread Milan Bouchet-Valat
Le samedi 02 mars 2013 à 12:37 -0500, Michael Friendly a écrit : I have a print method for a set of statistical tests, vcdExtra::CMHtest, for which I'd like to have more sensible printing of pvalues, as in print.anova(). [Testing this requires the latest version of vcdExtra, from R-Forge

Re: [R] print method like print.anova()

2013-03-02 Thread John Fox
Hi Michael, Take a look at ?printCoefmat. I hope this helps, John On Sat, 02 Mar 2013 12:37:36 -0500 Michael Friendly frien...@yorku.ca wrote: I have a print method for a set of statistical tests, vcdExtra::CMHtest, for which I'd like to have more sensible printing of pvalues, as in

[R] Errors-In-Variables in R

2013-03-02 Thread Cedric Sodhi
In reference to [1], how would you solve the following regression problem: Given observations (X_i,Y_i) with known respective error distributions (e_X_i,e_Y_i) (say, 0-mean Gaussian with known STD), find the parameters a and b which maximize the Likelihood of Y = a*X + b Taking the example

[R] how to log out from the conference

2013-03-02 Thread Quetzalcoatlus
Hello, please log me out from the conference. I tried to contact the webmaster but the only e-mail I reached was this one. Probably fault on my side in the registration. Thanks, Petr Suvorov [[alternative HTML version deleted]] __

Re: [R] How to start console output with a comment sign (as in knitr)

2013-03-02 Thread Marcus Kriele
Thanks Greg, this is great! Regards, Marcus On 2013-03-02, at 19:06 , Greg Snow wrote: Try the following to see if it does what you want: ## init con - textConnection(output, w) options(echo=FALSE) sink(con) addTaskCallback( function(expr, out, err, vis) { sink()

[R] easy way to install new R version??

2013-03-02 Thread capricy gao
Some packages have to be installed on new R version, 2.15.3 but I have 2.15.2 If I don't want to go through all download, and uninstall and install procedures, is there any simple R command that could handle this? Thanks. [[alternative HTML version deleted]]

Re: [R] explanation of the problem..

2013-03-02 Thread arun
HI Utpal, Alight, I will look into it.  I was under the impression that this is what you wanted: dat1- structure(list(V1 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L), V2 = c(1L, 1L, 1L, 1L, 1L, 1L, 0L), V3 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L),     V4 = c(1L, 1L, 0L, 1L, 1L, 1L, 1L), V5 = c(1L, 1L, 1L, 1L,    

Re: [R] easy way to install new R version??

2013-03-02 Thread Gabor Grothendieck
On Sat, Mar 2, 2013 at 1:49 PM, capricy gao capri...@yahoo.com wrote: Some packages have to be installed on new R version, 2.15.3 but I have 2.15.2 If I don't want to go through all download, and uninstall and install procedures, is there any simple R command that could handle this? Thanks.

Re: [R] xYplot help

2013-03-02 Thread Frank Harrell
xYplot has many options that are passed to panel.xYplot. Did you read the documentation? You can suppress labels, use an automatically generated Key() function to control where you want keys, and use several other options. Start with label.curve=FALSE and go from there. Frank bwr87 wrote I'm

Re: [R] Expressions in lattice conditional variables

2013-03-02 Thread Peter Ehlers
Frank, As you probably realize, the problem is not with lattice but with unique (actually: .Internal(unique, ...)): unique(expression('a','b','b')) generates your error. Lattice needs a factor variable for the panels, and it tries to use unique() on your 'vn' to do that. For example, if

Re: [R] using reserved words in R, and reuse variable names in different functions

2013-03-02 Thread Peter Ehlers
Duncan's comment may not qualify as a fortune, but it did make me chuckle. Peter Ehlers On 2013-03-02 03:01, Duncan Murdoch wrote: On 13-03-01 8:35 PM, C W wrote: [...snip...] pie is a function, but all it does is draw pie charts, so who cares if you mask it? :-). Duncan Murdoch

Re: [R] Errors-In-Variables in R

2013-03-02 Thread Rui Barradas
There's a no homework policy in R-help. Rui Barradas Em 02-03-2013 18:28, Cedric Sodhi escreveu: In reference to [1], how would you solve the following regression problem: Given observations (X_i,Y_i) with known respective error distributions (e_X_i,e_Y_i) (say, 0-mean Gaussian with known

[R] caret pls model statistics

2013-03-02 Thread Charles Determan Jr
Greetings, I have been exploring the use of the caret package to conduct some plsda modeling. Previously, I have come across methods that result in a R2 and Q2 for the model. Using the 'iris' data set, I wanted to see if I could accomplish this with the caret package. I use the following code:

Re: [R] Errors-In-Variables in R

2013-03-02 Thread Cedric Sodhi
Perhaps it would have been clearer that this is no homework if I hadn't forgotten to say what [1] is. Sorry for that. [1] https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15225 (This is no homework but genuinely adresses the problem that R to my knowledge does not have models for error in

[R] Raster images and saving with original pixel dimensions in tiff, jpeg, or png perferablly.

2013-03-02 Thread Hans Thompson
Hello R-Help, I want to be able to read in a raster image, plot it with grid.raster or rasterImage and save the image with one pixel per a pixel element from my array. Saved preferably in a common image format. The real goal of my question is to eventually read in images with text on them,

Re: [R] caret pls model statistics

2013-03-02 Thread Charles Determan Jr
I have discovered on of my errors. The timematrix was unnecessary and an unfortunate habit I brought from another package. The following provides the same R2 values as it should, however, I still don't know how to retrieve Q2 values. Any insight would again be appreciated: library(caret)

Re: [R] Errors-In-Variables in R

2013-03-02 Thread R. Michael Weylandt
Based on your comments in the (not-a-)bug report, I *think* this might help: quanttrader.info/public/betterHedgeRatios.pdf or more generally, the idea of total least squares regression. Cheers, MW On Sat, Mar 2, 2013 at 9:55 PM, Cedric Sodhi man...@gmx.net wrote: Perhaps it would have been

[R] Metafor SMCR Pre-Post Effect sizes

2013-03-02 Thread Markus Kösters
Dear all, I am very grateful that Wolfgang Viechtbauer implemented the standardised mean change for dependent groups. I was playing around a bit today, and I am not sure if I understand the SMCR procedure correctly. The documentation states that sd1i and sd2i are needed, but it seems to me

Re: [R] using reserved words in R, and reuse variable names in different functions

2013-03-02 Thread Rolf Turner
Well *I* think it should be a fortune! cheers, Rolf On 03/03/2013 10:30 AM, Peter Ehlers wrote: Duncan's comment may not qualify as a fortune, but it did make me chuckle. Peter Ehlers On 2013-03-02 03:01, Duncan Murdoch wrote: On 13-03-01 8:35 PM, C W wrote: [...snip...]

Re: [R] Errors-In-Variables in R

2013-03-02 Thread Rui Barradas
Hello, Like you say, apparently R doesn't have models for error in variables. But R packages might have. library(sos) findFn('errors-in-variables') Some look promising. Hope you find something. Rui Barradas Em 02-03-2013 21:55, Cedric Sodhi escreveu: Perhaps it would have been clearer that

Re: [R] Errors-In-Variables in R

2013-03-02 Thread David Winsemius
On Mar 2, 2013, at 1:55 PM, Cedric Sodhi wrote: Perhaps it would have been clearer that this is no homework if I hadn't forgotten to say what [1] is. Sorry for that. [1] https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15225 (This is no homework but genuinely adresses the problem

[R] if value is in vector, perform this function

2013-03-02 Thread Louise Stevenson
Hi, I'm trying to set up R to run a simulation of two populations in which every 3.5 days, the initial value of one of the populations is reset to 1.5. I'm simulation an experiment we did in which we fed Daphnia populations twice a week with algae, so I want the initial value of the algal

Re: [R] Empirical Bayes Estimator for Poisson-Gamma Parameters

2013-03-02 Thread Nicole Ford
just seeing this. when you say y1 and y2, are you asking about 2 differnt models in an effort to model select? i need more info, i might be able to help. please supply a bit more info. ~n On Feb 25, 2013, at 4:39 AM, Ali A. Bromideh wrote: Dear Sir/Madam, I apologize for any

Re: [R] Empirical Bayes Estimator for Poisson-Gamma Parameters

2013-03-02 Thread Nicole Ford
also, kruschke at indiana has some info on this, both online and youtube. (if homework.) if not, more infor will be helpful. ~n On Feb 25, 2013, at 9:41 AM, Bert Gunter wrote: Homework? We don't do homework here. If not, search (e.g. via google -- R hierarchical Bayes -- or some such).

Re: [R] Ordering Table Columns

2013-03-02 Thread Pete Brecknock
cdouglass wrote Hello all, Totally new to this and I'm just doing a frequency distribution analysis on T-shirt sales by size. I have a .csv with 60 orders. I read in the data using read.csv. If I look at the summary() or table() of the data it looks fine, except that the shirt sizes are

Re: [R] caret pls model statistics

2013-03-02 Thread Max Kuhn
Charles, You should not be treating the classes as numeric (is virginica really three times setosa?). Q^2 and/or R^2 are not appropriate for classification. Max On Sat, Mar 2, 2013 at 5:21 PM, Charles Determan Jr deter...@umn.eduwrote: I have discovered on of my errors. The timematrix was