[R] New reshape2 question

2014-08-13 Thread Neotropical bat risk assessments
Hi all, Thanks go out to those who provided helpful suggestions last year with a similar issue. I am working with a new data set and trying what I assumed was a simple aggregation in reshape2 but is not working. I have a large number of similar data sets to run so getting the code correct

Re: [R] Cox regression model for matched data with replacement

2014-08-13 Thread Therneau, Terry M., Ph.D.
On 08/13/2014 05:00 AM, John Purda wrote: I am curious about this problem as well. How do you go about creating the weights for each pair, and are you suggesting that we can just incorporate a weight statement in the model as opposed to the strata statement? And Dr. Therneau, let's say I

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread John McKown
On Tue, Aug 12, 2014 at 7:14 PM, Adrian Johnson oriolebaltim...@gmail.com wrote: Hi: sorry I have a basic question. I have a data frame with two columns: x1 V1 V2 1 AKT3TCL1A 2 AKTIPVPS41 3 AKTIPPDPK1 4 AKTIP GTF3C1 5 AKTIPHOOK2 6 AKTIPPOLA2

[R] scale_*_manual in ggplot2

2014-08-13 Thread Pavneet Arora
Data this is the data I used for the following problems: dput(sdf) structure(list(weeks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), values = c(9.45, 7.99, 9.29, 11.66, 12.16, 10.18, 8.04, 11.46, 9.2, 10.34, 9.03, 11.47,

Re: [R] Cox regression model for matched data with replacement

2014-08-13 Thread Therneau, Terry M., Ph.D.
Ok, I will try to do a short tutorial answer. 1. The score statistic for a Cox model is a sum of (x - xbar), where x is the covariate vector of the subject who had an event, and xbar is the mean covariate vector for the population, at that event time. - the usual Cox model uses the mean of

Re: [R] Cox regression model for matched data with replacement

2014-08-13 Thread Therneau, Terry M., Ph.D.
On 08/13/2014 08:38 AM, John Pura wrote: Thank you for the reply. However, I think I may not have clarified what my cases are. I'm studying the effect of radiation treatment (vs. none) on survival. My cases are patients who received radiation and controls are those who did not. I used a

Re: [R] Prediction intervals (i.e. not CI of the fit) for monotonic loess curve using bootstrapping

2014-08-13 Thread Jan Stanstrup
Thanks to all of you for your suggestions and comments. I really appreciate it. Some comments to Dennis' comments: 1) I am not concerned about predicting outside the original range. That would be nonsense anyway considering the physical phenomenon I am modeling. I am, however, concerned that

Re: [R] Prediction intervals (i.e. not CI of the fit) for monotonic loess curve using bootstrapping

2014-08-13 Thread Roger Koenker
To follow up on David's suggestion on this thread, I might add that the demo(predemo) in my quantreg package illustrates a variety of approaches to prediction intervals for quantile regression estimates. Adapting this to monotone nonparametric estimation using rqss() or cobs would be quite

[R] Parameter of a function used after $ in a data frame

2014-08-13 Thread madhvi.gupta
Hi, Can anyone please tell me how to use a argument of a function after $ sign of a data frame.That argument is one of the column name of the data frame. Thanks, Madhvi __ R-help@r-project.org mailing list

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread Adrian Johnson
Hi. Thank you for your help. yes, thats exactly right - but the 1211x1211 matrix has some row/column elements that may not be present in x1. Is that the reason I get this error? My matrix row names and column names are identical. I changed the order in my dput code for representational purpose so

Re: [R] Parameter of a function used after $ in a data frame

2014-08-13 Thread Rui Barradas
I don't believe I understand your question, but here it goes. dat - data.frame(x = rnorm(100), y = runif(100)) mean(dat$x) Hope this helps, Rui Barradas Em 13-08-2014 12:33, madhvi.gupta escreveu: Hi, Can anyone please tell me how to use a argument of a function after $ sign of a data

Re: [R] Parameter of a function used after $ in a data frame

2014-08-13 Thread William Dunlap
Use [[ instead of $. E.g., f - function(columnName) { d - data.frame(x=1, y=2, z=3) d[[columnName]] } f(z) # 3 cName - y f(cName) # 2 Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Aug 13, 2014 at 4:33 AM, madhvi.gupta madhvi.gu...@orkash.com wrote: Hi, Can anyone please tell

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread William Dunlap
You can replace the loop for (i in nrow(x1)) { x[x1$V1[i], x1$V2[i]] - 1; } by f - function(x, x1) { i - as.matrix(x1[, c(V1,V2)]) # 2-column matrix to use as a subscript x[ i ] - 1 x } f(x, x1) You will get an error if not all the strings in the subscript matrix are in the row or

Re: [R] A basic statistics question

2014-08-13 Thread Ted Harding
On 12-Aug-2014 22:22:13 Ted Harding wrote: On 12-Aug-2014 21:41:52 Rolf Turner wrote: On 13/08/14 07:57, Ron Michael wrote: Hi, I would need to get a clarification on a quite fundamental statistics property, hope expeRts here would not mind if I post that here. I leant that

[R] find the data frames in list of objects and make a list of them

2014-08-13 Thread Matthew
Hi everyone, I would like the find which objects are data frames in all the objects I have created ( in other words in what you get when you type: ls() ), then I would like to make a list of these data frames. Explained in other words; after typing ls(), you get the names of objects.

Re: [R] find the data frames in list of objects and make a list of them

2014-08-13 Thread jim holtman
Here is a function that I use that might give you the results you want: = my.ls() Size Class Length Dim .Random.seed 2,544integer 626 .remapHeaderFile 40,440 data.frame 2 373 x 2 colID 216

Re: [R] find the data frames in list of objects and make a list of them

2014-08-13 Thread Richard M. Heiberger
I would do something like this lsDataFrame - function(xx=ls()) xx[sapply(xx, function(x) is.data.frame(get(x)))] ls(package:datasets) lsDataFrame(ls(package:datasets)) On Wed, Aug 13, 2014 at 2:56 PM, Matthew mccorm...@molbio.mgh.harvard.edu wrote: Hi everyone, I would like the find which

Re: [R] find the data frames in list of objects and make a list of them

2014-08-13 Thread Matthew
Jim, Wow that was cl ! This function is *really* useful. Thank you very much ! (It is also way beyond my capability). I need to make a list of data frames because then I am going to bind them with plyr using 'dplyr::rbind_all(listOfDataFrames)'. This will make a single data frame, and

[R] save results in a loop

2014-08-13 Thread Wenlan Tian
Hi, i'm new to R. I have a question about how to save results in a loop to a file. Here is an example: for (i in 6:n){ Tukey1 = HSD.test(lm(sdata_mg[,n] ~ sdata_mg$Medium+sdata_mg$color+sdata_mg$type+sdata_mg$Micro), 'sdata_mg$Micro') } I don't know how to do it with the loop for all data, so i

Re: [R] save results in a loop

2014-08-13 Thread Greg Snow
Generally if you want to save the results of a loop then it is time to learn to use the lapply and sapply functions instead. Try something like: Tukey - lapply( 6:n, function(i) Tukey1 = HSD.test(lm(sdata_mg[,i] ~ sdata_mg$Medium+sdata_mg$color+sdata_mg$type+sdata_mg$Micro), 'sdata_mg$Micro') )

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread Adrian Johnson
Hello again. sorry for question again. may be I was not clear in asking before. I don't want to remove rows from matrix, since row names and column names are identical in matrix. I tried your suggestion and here is what I get: fx - function(x,x1){ + i - as.matrix(x1[,c(V1,V2)]) + x[i]-1 + x

[R] opinion - sharing problem data and other stuff.

2014-08-13 Thread John McKown
This is just a thought that has occurred to me. I don't know if it is an Oh, WOW! or an Are you KIDDING?!? type thought. So I thought I'd ask here. I use github for a few things. Nothing great, but maybe nice. Anyway, one feature of GitHub is the GIST feature. What I am used to github being for

Re: [R] opinion - sharing problem data and other stuff.

2014-08-13 Thread Sarah Goslee
Hi John, People do sometimes link to external data and code, though I'm not sure I've seen any in that particular format. But, two things to consider. A. I'm lazy. If the problem is fully-formed in the email, I'm more likely to try to solve it than if I have to go download something and figure

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread William Dunlap
I may have missed something, but I didn't see the result you want for your example. Also, none of the entries in the x1 you showed are row or column names in x, making it hard to show what you want to happen. Here is a function that gives you the choice of *error: stop if any row of x1 is

Re: [R] populating matrix with binary variable after matching data from data frame

2014-08-13 Thread William Dunlap
Another solution is to use table to generate your x matrix, instead of trying to make one and adding to it. If you want the table to have the same dimnames on both sides, make factors out of the columns of x1 with the same factor levels in both. E.g., using a *small* example: X1 -

Re: [R] opinion - sharing problem data and other stuff.

2014-08-13 Thread Jeff Newmiller
Hear, hear. Getting the questioner to slow down and look at what they really want is key, because if they don't know what they want then their question will be unclear, and I hate answering a question that was never really what the OP was looking for in the first place. One problem I have

Re: [R] find the data frames in list of objects and make a list of them

2014-08-13 Thread Matthew
Hi Richard, Thank you very much for your reply and your code. Your code is doing just what I asked for, but does not seem to be what I need. I will need to review some basic R before I can continue. I am trying to list data frames in order to bind them into 1 single data frame with

Re: [R] find the data frames in list of objects and make a list of them

2014-08-13 Thread William Dunlap
Previously you asked A second question: is this the best way to make a list of data frames without having to manually type c(dataframe1, dataframe2, ...) ? If you use 'c' there you will not get a list of data.frames - you will get a list of all the columns in the data.frame you

Re: [R] Prediction intervals (i.e. not CI of the fit) for monotonic loess curve using bootstrapping

2014-08-13 Thread David Winsemius
On Aug 12, 2014, at 8:40 AM, Bert Gunter wrote: PI's of what? -- future individual values or mean values? I assume quantreg provides quantiles for the latter, not the former. (See ?predict.lm for a terse explanation of the difference). I probably should have questioned the poster about

Re: [R] Multivariate tobit regression

2014-08-13 Thread Jeff Newmiller
RSiteSearch(tobit) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#..

[R-es] NA no es reconocido como NA

2014-08-13 Thread neo
Estimada comunidad, tengo el siguiente problema: Tengo una tabla de datos de 563 x 7, de las 7 columnas las 4 primeras son de identificacion de una muestra y las 3 ultimas identifican a una variable respuesta medida en esa muestra. Hay varias respuestas para cada muestra y la cantidad de

Re: [R-es] NA no es reconocido como NA

2014-08-13 Thread Igor Sosa Mayor
neo ericconchamu...@gmail.com writes: fila n-1 columna j en (n,j) ... aqui es donde esta el problema pues la instruccion IF no reconoce los elementos NA como NA y el ciclo pasa sin completar copiar nada en la fila n, me explico ? envio el codigo y el archivo que estoy usando a ver si alguien

Re: [R-es] NA no es reconocido como NA

2014-08-13 Thread neo
gracias igor, voy a probar, slds, eric. On 13/08/14 15:34, Igor Sosa Mayor wrote: neo ericconchamu...@gmail.com writes: fila n-1 columna j en (n,j) ... aqui es donde esta el problema pues la instruccion IF no reconoce los elementos NA como NA y el ciclo pasa sin completar copiar nada

Re: [R-es] NA no es reconocido como NA

2014-08-13 Thread David Suárez
Según la ayuda de la función read.table: ?read.table . . . na.strings: a character vector of strings which are to be interpreted as ‘NA’ values. Blank fields are also considered to be missing values in logical, integer, numeric and complex fields. NA o es el valor