Displaying 2 results from an estimated 2 matches for "testdf2".
Did you mean:
testdf
2007 Nov 08
2
mapply, coxph, and model formula
...<- function(n) {
times <- sample(1:200, n, replace = TRUE)
event <- rbinom(n, 1, prob = .1)
trt <- rep(c("A","B"), each = n/2)
testdf <- data.frame(times,event,trt)
}
#Create two sets of test data of different sizes
testdf1 <- makeTestDF(100)
testdf2 <- makeTestDF(200)
#Define a formula and call coxph
form <- Surv(times, event) ~ trt
coxph(form, testdf1) #Works
coxph(form, testdf2) #Works
#Create a list of the two data.frames
df.list <- list(testdf1, testdf2)
#Try to use mapply
mapply(coxph, form, df.list)
### END R SAMPLE CODE ###...
2010 Sep 18
0
Saving long character variable to database saves timestamp instead
...")
I then save it to the database and pull it out again to a new database:
> require(RODBC)
> pg <- odbcConnect("DSN", uid="postgres", pwd="***", case="tolower")
> sqlSave(pg, testdf, "testdf", rownames = FALSE, append = TRUE)
> testdf2 <- sqlQuery(pg, "SELECT * FROM testdf", stringsAsFactors = FALSE)
The longest variable wasn't saved correctly:
> nchar(testdf$chars)
[1] 30000 35000
> nchar(testdf2$chars)
[1] 30000 19
A timestamp was saved instead:
> testdf2$chars[2]
[1] "2010-09-18 00:00:00&quo...