search for: datnew

Displaying 10 results from an estimated 10 matches for "datnew".

2013 Jun 25
1
censor=FALSE and id options in survfit.coxph
...- pmin(y, 2) # observation time dat <- data.frame(x,z,y,e) # fit cox model with start/stop format library(survival) mod <- coxph(Surv(z, y, e)~x, data=dat) summary(mod) # create prediction dataset with 3 individuals with # x = 0 on (0,2) # x = 1 on (0,2) # x = 0 on (0,1) and x = 1 on (1,2) datnew <- data.frame(x=c(0,1,0,1), z=c(0,0,0,1), y=c(2,2,1,2), e=rep(0,4), id=c(1,2,3,3)) datnew # as expected modsf1 <- survfit(mod, newdata=datnew, id=id) modsf1 # not as expected modsf2 <- survfit(mod, newdata=datnew, id=id, censor=FALSE) modsf2 # for comparison modsf3 <- survfit(mod, n...
2013 May 23
3
Removing rows w/ smaller value from data frame
Hello, I have a column called max_date in my data frame and I only want to keep the bigger values for the same activity. How can I do that? data frame: activity max_dt A 2013-03-05 B 2013-03-28 A 2013-03-28 C 2013-03-28 B 2013-03-01 Thank you for your help -- View this message in context:
2012 Mar 08
2
Boxplot Fill Pattern
...;Mount Pisgah","South Eugene") colors = c("gray","red","white","blue","yellow","purple","orange") # Fake data here: site = rep(site.txt, each = 21) sp = rep(rep(leg.txt, each = 3), times = 7) ga = runif(147, 0, 20) datnew.lo = data.frame(site,sp,ga) # Now make the plot: boxplot(ga~sp*site,data=datnew.lo, range = 1, col = colors, ylim = c(0,30), xaxt = "n", xlab = "Site", ylab = "Basal Area Growth Increment", main = "Basal Area Growth...
2013 Mar 27
9
conditional Dataframe filling
Hi everyone: This may be trivial but I just have not been able to figure it out. Imagine the following dataframe: a b c d TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE I would like to create a new dataframe, in which TRUE gets 0 but if false then add 1 to the cell to the left. So the results for the example above should be something like: a b c
2013 Nov 05
0
Sampling question
...ion(i) { ??? ??? ??? x1 <- dat[i,6:9][is.na(match(gsub("^.","",names(dat[i,6:9])),gsub("^.","",names(lst1[[i]][1]))))] ??? ??? ??? ?cbind(lst1[[i]][1], sample(x1,3)) ??? ??? ??? ??? ??? ??? ??? } ??? ??? ??? ??? ) ?do.call(rbind,lapply(lst1,function(x) {datNew <- cbind(SubID= as.numeric(row.names(x)), x); names(datNew)[-1] <- "var"; datNew})) }) res } ?res1 <- fun1(dat1,5) lst2 <- lapply(split(res1,col(res1)), function(x) {dat <- do.call(cbind,x); colnames(dat) <- c("SubID", rep("var",4));dat}) do.call(cb...
2013 Mar 19
4
Copying rows in data frames
Hi, I'm trying to copy the first row of one data frame to another. This is the statement I am using : df2[1,]<-df1[1,]; I have printed them out separately: df1[1,] = A C D E F But after copying: df2[1,] = 96 29 88 122 68 Why isn't it copying? They are both data frames, and "as.character" isn't working either. Thanks for your input :) [[alternative HTML version
2013 Apr 12
5
how to change the date into an interval of date?
...?????????? 2 1????????????????? 15-02-2010?????????????????????????????????? 2????????????????????????????????????????????? 3 1?????????????????? 01-04-2010????????????????????????????????? 3????????????????????????????????????????????? 2 ",sep="",header=TRUE,stringsAsFactors=FALSE) datNew<- dat1 datNew$responsed_at<- gsub("^.*\\-(.*\\-.*)","\\1", datNew$responsed_at) dat2<-data.frame(responsed_at=format(seq(from=as.Date("01-01-2010",format="%d-%m-%Y"),to=as.Date("01-04-2010",format="%d-%m-%Y"),by="month")...
2013 Feb 01
29
cumulative sum by group and under some criteria
Thank you very much for your reply. Your code work well with this example. I modified a little to fit my real data, I got an error massage. Error in split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...) : Group length is 0 but data length > 0 On Thu, Jan 31, 2013 at 12:21 PM, arun kirshna [via R] < ml-node+s789695n4657196h87@n4.nabble.com> wrote: > Hi, > Try this: >
2009 Apr 10
4
split a character variable into several character variable by a character
Dear Mao Jianfeng, "r-help-owner" is not the place for help, but: r-help at r-project.org (CC-ed here) In any case, strsplit() does the job, i.e.: > unlist(strsplit("BCPy01-01", "-")) [1] "BCPy01" "01" You can work with the whole variable, like: splitpop <- strsplit(df1$popcode, "-") then access the first part with >
2013 Mar 11
0
splitting column into two
...589 #2? chr1 564620 564649?? 94? +? 10???? 564644?? 564645 #3? chr1 565369 565404? 217? +?? 8???? 565371?? 565372 #4? chr1 565463 565541 1214? +? 15???? 565480?? 565481 #5? chr1 565653 565697 1031? +? 28???? 565662?? 565663 #6? chr1 565861 565922? 316? +? 12???? 565883?? 565884 library(data.table) datNew<- data.table(dat2) A.K. ----- Original Message ----- From: "deconstructed.morning at gmail.com" <deconstructed.morning at gmail.com> To: smartpink111 at yahoo.com Cc: Sent: Sunday, March 10, 2013 5:48 PM Subject: Re: splitting column into two Hello, I saw your solution for t...