Re: [R] Generating Patient Data

2014-06-25 Thread David Winsemius
On Jun 24, 2014, at 10:14 PM, Abhinaba Roy wrote: Dear R helpers, I want to generate data for say 1000 patients (i.e., 1000 unique IDs) having suffered from various diseases in the past (say diseases A,B,C,D,E,F). The only condition imposed is that each patient should've suffered from

Re: [R] Generating Patient Data

2014-06-25 Thread Abhinaba Roy
Hi David, I was thinking something like this: ID Disease 1 A 2 B 3 A 1C 2D 5A 4B 3D 2A .... How can this be done? On Wed, Jun 25, 2014 at 11:34 AM, David Winsemius dwinsem...@comcast.net wrote: On Jun 24, 2014, at 10:14 PM, Abhinaba Roy wrote:

Re: [R] Generating Patient Data

2014-06-25 Thread Anthony Damico
# build off of david's suggestion x - data.frame( patient= 1:20 , disease = sapply( pmin( 2 + rpois( 20 , 2 ) , 6 ) , function( n ) paste0( sample( c('A','B','C','D','E','F'), n), collapse=+ ) ) ) # break the diseases

[R] SD of Residuals by group

2014-06-25 Thread Katharina Mersmann
Dear Community, I emphasize the use of graphical methods to examine residuals for a Panel model and want to plot the Standard Deviation of residuals by group. I used the following for plotting residuals by group: library(lattice) xyplot((residuals(fixed.reg1.1))~countrynr,data=data.plm)

[R] matlab serial date to r

2014-06-25 Thread Christoph Schlächter
Hi, I have a matlab variable as serial date (class double) in the form 'dd-mmm- HH:MM:SS'. format long disp( tx(40:60,1) ) 1.0e+05 * 7.35600813091 7.35600956856 7.35601305921 7.35601654985 7.35602004049 7.35602353113 7.35602702178

Re: [R] saving a 'get' object in R

2014-06-25 Thread David Stevens
Greg - I appreciate your taking the time to explain. This is very helpful. My case was a bit unusual as I'm helping a colleague with code to use on a regular but individual basis. I want them to name a data set once at the top of the script and have that name propagate through several objects

Re: [R] saving a 'get' object in R

2014-06-25 Thread Jeff Newmiller
Seems to me you are creating your own troubles in your requirements. If the analysis is the same from case to case, it makes more sense to use a single set of object names within the analysis and change only the names of the input and output files.

Re: [R] saving a 'get' object in R

2014-06-25 Thread Bert Gunter
... and wrap it all up into a single function call that could even have the user interactively supply the input data file names. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not

Re: [R] matlab serial date to r

2014-06-25 Thread Prof Brian Ripley
See ?as.Date. I am guessing these are days and fractional days. Try x - 7.35600813091e5 as.POSIXct((x - 719529)*86400, origin = 1970-01-01) On 25/06/2014 14:56, Christoph Schlächter wrote: Hi, I have a matlab variable as serial date (class double) in the form 'dd-mmm- HH:MM:SS'.

Re: [R] matlab serial date to r

2014-06-25 Thread Jeff Newmiller
I think the character format for this data is the most versatile and clear option. You do have to prevent the R input function (read.csv? read.table?) from converting it to factor when you read it in, but then you can use as.POSIXct with a format argument (see ?strptime) to obtain useful

Re: [R] Generating Patient Data

2014-06-25 Thread arun
Hi, Check if this works:  set.seed(495)  dat - data.frame(ID=sample(1:10,20,replace=TRUE), Disease=sample(LETTERS[1:6], 20, replace=TRUE) ) subset(melt(table(dat)[rowSums(!!table(dat))1,]), !!value,select=1:2)    ID Disease 1   2   A 3   4   A 4   6   A 6  10   A 8   3  

Re: [R] matlab serial date to r

2014-06-25 Thread arun
Hi, May be this helps: dat - read.table(text=7.35600813091   7.35600956856   7.35601305921   7.35601654985   7.35602004049   7.35602353113   7.35602702178   7.35603397179   7.35604092182   7.35604787183   7.35605482185   7.35606177187  

[R] Duncan test: 2-way ANOVA without repetition, but with multiple subjects

2014-06-25 Thread Rosario Garcia Gil
Hello I have a question on how to perform a Duncan test after I set a model like this (see below). The data consist of a dependent variable (PHt) and two dependent variables (REGION (3 levels) AND MANAGEMENT (3 levels)). MANAGEMENT N PS REGION A 196 196

Re: [R] Generating Patient Data

2014-06-25 Thread arun
Also, you can do: library(dplyr) dat%%group_by(ID)%%filter(length(unique(Disease))1)%%arrange(Disease,ID) A.K. On Wednesday, June 25, 2014 3:45 AM, arun smartpink...@yahoo.com wrote: Forgot about: library(reshape2) On , arun smartpink...@yahoo.com wrote: Hi, Check if this works:  

Re: [R] partykit ctree: minbucket and case weights

2014-06-25 Thread Torsten Hothorn
Dear Amber, your data contains missing values and you don't use surrogate splits to deal with them. So, the observations are passed down the tree randomly (there is no majority argument to ctree_control!) and thus it might happen that too small terminal nodes are created. Simply use

Re: [R] Duncan test: 2-way ANOVA without repetition, but with multiple subjects

2014-06-25 Thread Richard M. Heiberger
You didn't say which package Duncan.test is in. glht has the ability. glht, and probably any other package's test, cannot work with aovlist objects. They require aov objects. That means you must rewrite your Error() statement into the main model. Please see the entire maiz example in ?mmc to

[R] Simple permutation question

2014-06-25 Thread Robert Latest
So my company has hired a few young McKinsey guys from overseas for a couple of weeks to help us with a production line optimization. They probably charge what I make in a year, but that's OK because I just never have the time to really dive into one particular time, and I have to hand it to the

Re: [R] Simple permutation question

2014-06-25 Thread Cade, Brian
It is called sample(,replace=F), where the default argument is sampling without replacement. Try x - c(A,B,C,D,E) sample(x) Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: ca...@usgs.gov

Re: [R] Generating Patient Data

2014-06-25 Thread David Winsemius
On Jun 24, 2014, at 11:18 PM, Abhinaba Roy wrote: Hi David, I was thinking something like this: ID Disease 1 A 2 B 3 A 1C 2D 5A 4B 3D 2A .... How can this be done? do.call(rbind, lapply( 1:20, function(pt) { data.frame(

Re: [R] Simple permutation question

2014-06-25 Thread Ted Harding
I think Robert wants deterministic permutations. In the e1071 package -- load with library(e1071) -- there is a function permutations(): Description: Returns a matrix containing all permutations of the integers '1:n' (one permutation per row). Usage: permutations(n) Arguments: n:

[R] Join the TIBCO TERR team at useR 2014!

2014-06-25 Thread Louis Bajuk-Yorgan
The TERR team will be at useR 2014, June 30th to July 3rd, to share the latest enhancements and news around TIBCO Enterprise Runtime for R. In addition to providing demos at the TIBCO TERR table in the exhibition area, some of the senior members of the TERR team will be presenting at the

Re: [R] Simple permutation question

2014-06-25 Thread David L Carlson
Assuming you want all of the permutations not just a random permutation (such as sample() give you): require(e1071) indx - permutations(5) head(indx) [,1] [,2] [,3] [,4] [,5] [1,]12345 [2,]21345 [3,]23145 [4,]132

Re: [R] Simple permutation question

2014-06-25 Thread Bert Gunter
and further... See ?Recall for how to do recursion in R. However, it is my understanding that recursion is not that efficient in R. A chain of function environments must be created, and this does not scale well. (Comments from real experts welcome here). Cheers, Bert Bert Gunter Genentech

Re: [R] Simple permutation question

2014-06-25 Thread David L Carlson
A couple of typos in the last section. It should be perm.ltrs - apply(indx, 1, function(x) paste(LETTERS[x], collapse= )) tail(perm.ltrs) [1] E D A B C E D B A C E D B C A E D A C B E D C A B E D C B A tail(perm.ltrs) [1] E D A B C E D B A C E D B C A E D A C B E D C A B E D C B A David C

Re: [R] Simple permutation question

2014-06-25 Thread Jeff Newmiller
The brokenness of your perm.broken function arises from the attempted use of sapply to bind matrices together, which is not something sapply does. perm.fixed - function( x ) { if ( length( x ) == 1 ) return( matrix( x, nrow=1 ) ) lst - lapply( seq_along( x ) , function( i ) {

Re: [R] Simple permutation question

2014-06-25 Thread Jeff Newmiller
sorry... editing on the fly... try: perm.fixed - function( x ) { if ( length( x ) == 1 ) return( matrix( x, nrow=1 ) ) lst - lapply( seq_along( x ) , function( i ) { cbind( x[ i ], perm.fixed( x[ -i ] ) ) } ) do.call( rbind,

[R] plot a 3-D marked point process

2014-06-25 Thread Ferra Xu
Hello All I intend to plot a 3-D marked point process. Could you please help me to find a code or a related package? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] How to troubleshoot issue with curve() function?

2014-06-25 Thread Lavrenz, Steven M
I am trying to plot data that I imported with read. table using a Weibull distribution. Here's the code I used for importing the data: data - read.table(file = C:/Users/Steven/OneDrive/Unfiled/Temp/phase2.csv, header = FALSE, sep = ,, dec = ., col.names = c(cycle_time, cycle_length, red_time,

Re: [R] How to troubleshoot issue with curve() function?

2014-06-25 Thread Benno Pütz
I’d start trying to understand the error message - it is actually pretty clear (see ?curve). I suspect curve is not the function you want to use, rather something like plot(data$arrival_time, dexp(data$arrival_time, rate=0.06), xlim = c(0, 60), type=‘l’, main = Exponential distribution”)

Re: [R] plot a 3-D marked point process

2014-06-25 Thread Ben Bolker
Ferra Xu ferra.xu at yahoo.com writes: Hello All I intend to plot a 3-D marked point process. Could you please help me to find a code or a related package? How about scatterplot3d or rgl::plot3d ? Googling r 3d point plot gets you a lot of good starting points. (The easiest way to

[R] Space-time non-homogeneous Poisson process

2014-06-25 Thread Ferra Xu
I am wondering if I want to model a space-time non-homogeneous Poisson process that has more probability of occurrence in some areas in space, how should I do that? For example we want to model the intensity function of earthquake occurrence that is more probable to happen in some areas (around

Re: [R-es] Resumen de R-help-es, Vol 64, Envío 33

2014-06-25 Thread Marta valdes lopez
Hola, Gracias, me funciono¡ Echare un vistazo a lo de hacer las ROC dinamicas. Gracias por la ayuda, un saludo El 23 de junio de 2014, 16:42, Marta valdes lopez martavalde...@gmail.com escribió: Hola Pedro, Muchisimas gracias por tu respuesta, me há aclarado mucho. Es lo que veia que

Re: [R-es] curva ROC

2014-06-25 Thread Freddy Omar López Quintero
Hola. Seguramente ya lo intentaste, pero la forma quizá más inmediata es usando el paquete ROCR: library(ROCR) plot(performance(prediction(prediccion_tu_modelo, tu_variable_respuesta_binaria),tpr,fpr)) con prediccion_tu_modelo la predicción probabilística de tu modelo. Si tu modelo es un