similar to: wrapper for coxph with a subset argument

Displaying 20 results from an estimated 1200 matches similar to: "wrapper for coxph with a subset argument"

2007 Nov 08
2
mapply, coxph, and model formula
Hello - I am wanting to create some Cox PH models with coxph (in package survival) using different datasets. The code below illustrates my current approach and problem with completing this. ### BEGIN R SAMPLE CODE ############################## library(survival) #Define a function to make test data makeTestDF <- function(n) { times <- sample(1:200, n, replace = TRUE) event
2009 Sep 16
3
apply function across two variables by mult factors
Greetings, I am attempting to run a function, which produces a vector and requires two input variables, across two nested factor levels. I can do this using by(X, list(factor1, factor2), function), however I haven't found a simple way to extract the list output into an organized vector form. I can do this using nested loops but it isn't exactly an optimal approach. Thank you
2009 Mar 20
4
how to make aggregation in R ?
Hi, I am trying to aggregate the sum of my test data.frame as follow: testDF <- data.frame(v1 = c("a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "d", "d", "d", "d",
2011 Mar 09
2
SQLDF - Submitting Queries with R Objects as Columns
Fellow R programmers, I'd like to submit SQLDF statements with R objects as column names. For example, I want to assign "X" to "var1" (var1<-"X") and then refer to "var1" in the SQLDF statement. SQLDF needs to understand that when I reference "var1", it should look for "X" in the dataframe. This is necessary because my SQLDF
2008 Feb 26
1
wrapper for save function
Hello - I would like to create a wrapper to the 'save' function in the base package, but have a small problem with the name of the object that is getting saved in the file. Below is a simple example illustrating my problem. ## BEGIN SAMPLE R CODE ################################################## ## Here is the wrapper for the save function
2011 Jan 01
3
Retrieving Factors with Levels Ordered
Hello (and Happy New Year), When I create a factor with labels in the order I want, write the data as a text file, and then retrieve them, the factor levels are no longer in the proper order. Here is what I do (I tried many variations): # educ is a numeric vector with 1,001 observations. # There is one NA # Use educ to create a factor feducord <- factor(educ, labels = c('Elem',
2009 Jun 22
1
Problem with storing a sequence of lmer() model fit into a list
Dear R-helpers: May I ask a question related to storing a number of lmer model fit into a list. Basically, I have a for-loop (see towards the bottom of this email) in the loop, I am very sure that the i-th model fit (i.e.,fit_i) is successfully generated and the character string (i.e., tmp_i) is created correctly. The problem stems from the following line in the for-loop #trouble making line
2007 Dec 19
1
Different labels by panel in barchart
Dear all, I'm analysing a survey, and creating a barchart of the different responses for each question. The questions are grouped according to a number of categories, so I'm using lattice to create a plot with each question in a category on it. The problem is that the response set for different questions within the same category varies. I want to be able to draw only the relevant
2009 Feb 20
2
Grouped bwplots?
Dear list, I am sorry for asking you this, but I am trying to do again what I thought I have done before, although this time it does not work. So, given the data set: > testdf <- data.frame(grfak=sample(c("One","Two"),size=100,replace=TRUE), panfak= sample(c("Yes","No"),size=100,replace=TRUE), xfak=
2011 May 17
1
Dealing with null values Aggregate function
Hi R users I trying to some aggregate statistics on a very large dataset. The null values are causing a problem. I would like to calculate aggregate values for groups. I am just no sure how to deal with the "" I would ideally like them to ignored ie if there is only 1 value over several columns than that value would be the summary statistic. I have put the following example together to
2008 Apr 03
1
by "infelicity"
Dear list, Please find below an example of odd behaviour of the by function. It occurs both under GNU/Linux R 2.6.2 and Windows R 2.7.0alpha. Respective sessionInfo()'s are given below. I hope I do not overlook anything. testFactor <- factor(sample(LETTERS[1:6], size = 42, replace = TRUE)) testMatrix <- matrix(rnorm(42 * 6), nrow = 42) testDf <- as.data.frame(testMatrix) by(data
2013 Oct 07
1
Why read.table replacing space with "." in the header
Hi, Use `check.names=FALSE` head(dd,2) #? Phylo.Tree Genesis.Tree #1????????? 1??????????? 2 #2????????? 2??????????? 3 ?dd <- data.frame("Phylo Tree"= c(1:10), "Genesis Tree"= c(2:11),check.names=FALSE) head(dd,2) #? Phylo Tree Genesis Tree #1????????? 1??????????? 2 #2????????? 2??????????? 3 write.csv(dd,"Crish.csv",row.names=FALSE) ?yy<-
2006 Mar 29
1
calcualtign a trailing 12 column mean in a dataframe?
I have a dataframe of 25 columns and 100,000 rows called ?testdf?. I wish to build a new dataframe, with 14 columns and 100,000 rows. I wish the new dataframe to have the ?trailing 12 column? mean. That is, I want column 1 of the new dataframe to have soemthing like: ?( mean(testdf[,1:12],na.rm=T)? What is the best way to accomplish this?
2011 Jul 01
4
Access only part of last dimension of table/matrix
I would like to do some operations inside a function using only one value for the last dimension of a table/matrix: tabfn <- function (dfrm, facvec, YN ="event"){ return( Etbl <- do.call(table, dfrm[ , c(facvec, "event") ]) ) # just want Etbl[,,,"TRUE"] or Etbl[,, "TRUE"] or Etbl[,"TRUE"] }
2017 Aug 28
0
help with read.csv() for files with different number of columns
Hi Ace, With tabs as separators: testdf<-read.table("test.txt",header=FALSE,fill=TRUE,sep="\t", col.names=paste("V",1:19,sep=""),stringsAsFactors=FALSE) Also note that I got the number of columns wrong the first time. Jim On Mon, Aug 28, 2017 at 12:56 PM, Fix Ace <acefix at rocketmail.com> wrote: > Hi, Jim, > > Thank you very much for
2017 Aug 29
2
help with read.csv() for files with different number of columns
Thank you very much! Looks like I have to know the length of each record ahead of time. Ace On Monday, August 28, 2017 12:56 AM, Jim Lemon <drjimlemon at gmail.com> wrote: Hi Ace, With tabs as separators: testdf<-read.table("test.txt",header=FALSE,fill=TRUE,sep="\t", col.names=paste("V",1:19,sep=""),stringsAsFactors=FALSE) Also note
2014 Mar 19
2
Posible error en la documentación de "aggregate"
Hola compañeros, estaba utilizando la función "aggregate" y quería que tuviese en cuenta los NAs. He leido la documentación de dicha función y aparece esto: # and if you want to treat NAs as a group fby1 <- factor(by1, exclude = "") fby2 <- factor(by2, exclude = "") aggregate(x = testDF, by = list(fby1, fby2), FUN = "mean")
2017 Aug 29
0
help with read.csv() for files with different number of columns
Hi Ace, You can just read the file first to find out: max_fields<-function(file,sep=" ") { rlines<-readLines(file) return(max(unlist(lapply(sapply(rlines,strsplit,sep),length)))) } nmax<-max_fields(test.txt,"\t") Jim On Wed, Aug 30, 2017 at 2:22 AM, Fix Ace <acefix at rocketmail.com> wrote: > Thank you very much! Looks like I have to know the length of
2010 Sep 18
0
Saving long character variable to database saves timestamp instead
When saving a data frame with long character variable, approximately longer than 30000 characters, to a text field in PostgreSQL, using RODBC on Windows XP, I get a timestamp saved to the database instead. Is there any way to extend the number of characters that a text variable can receive? Here are the details of my case (simplified): I'm using PostgreSQL to create a table CREATE TABLE
2012 Nov 13
0
GAM model to reduce PACF of a model
I have asked this question on Stackoverflow and was told it does not relate to the sites' mission as it is statistical question, thus I brought it here. I am fitting a gam mode in the mgcv package to study associations of environmental pollutants and mortality. The aim is to choose a model with lowest mgcv and also to reduce the PACF to less than < |0.1|. library(gamair) library(mgcv)