similar to: applying a set of rules to each row

Displaying 20 results from an estimated 90 matches similar to: "applying a set of rules to each row"

2012 Jan 24
6
Checking for invalid dates: Code works but needs improvement
Hello Everyone, Still new to R. Wrote some code that finds and prints invalid dates (see below). This code works but I suspect it's not very good. If someone could show me a better way, I'd greatly appreciate it. Here is some information about what I'm trying to accomplish. My sense is that the R date functions are best at identifying invalid dates when fed character data in their
2012 Jan 18
4
R-Help
I am trying to create a frequency distribution and I am a bit confused. Here are the commands I have entered: > data <- read.csv(file="40609_sortedfinal.csv",head=TRUE,sep=",") > NumberOfActionsByStatus = data$STATUS > NumberOfActionsByUser = data$ETS_LOGIN > NumberOfBidOffer = data$BID_OFFER > NumberOfActionsByUser.freq = table(NumberOfActionsByUser) >
2012 Jan 26
0
R-help Digest, Vol 107, Issue 25
Hi Rui, Thanks for your reply to my post. My code still has various shortcomings but at least now it is fully functional. It may be that, as I transition to using R, I'll have to live with some less than ideal code, at least at the outset. I'll just have to write and re-write my code as I improve. Appreciate your help. Paul Message: 66 Date: Tue, 24 Jan 2012 09:54:57 -0800 (PST)
2018 Jan 15
1
Time-dependent coefficients in a Cox model with categorical variants
Suppose I have a dataset contain three variants, looks like > head(dta) Sex tumorsize Histology time status 0 1.5 2 12.1000 0 1 1.8 1 38.4000 0 ..................... Sex: 1 for male; 0 for female., two levels Histology: 1 for SqCC; 2 for High risk AC; 3 for low risk AC,
2008 Mar 20
3
Problem with diff(strptime(...
Hi all, I have been chipping away at a problem I encountered in calculating rates per year from a moderately large data file (46412 rows). When I ran the following command, I got obviously wrong output: interval<- c(NA,as.numeric(diff( strptime(mkdf$MEAS_DATE,"%d/%m/%Y")))/365.25) The values in MEAS_DATE looked like this: mkdf$MEAS_DATE[1:10] [1] 1/5/1962 1/5/1963
2007 Sep 24
2
Calculate difference between dates in years
Hello, I would like to be able to calculate the age of someone at a particular date. Both dates are date objects. Here is what I have come up with: floor(as.numeric(sampleInfo$Date.of.DIAGNOSIS-sampleInfo$Date.of.birth)/365.25) Is this the best approach? or is there an inbuilt function? I have looked at difftime but that does not seem to allow output in years. Many thanks Dan --
2010 Nov 24
2
Is there an equivalent to predict(..., type="linear") of a Proportional hazard model for a Cox model instead?
Hi all, Is there an equivalent to predict(...,type="linear") of a Proportional hazard model for a Cox model instead? For example, the Figure 13.12 in MASS (p384) is produced by: (aids.ps <- survreg(Surv(survtime + 0.9, status) ~ state + T.categ + pspline(age, df=6), data = Aidsp)) zz <- predict(aids.ps, data.frame(state = factor(rep("NSW", 83), levels =
2007 Oct 25
1
Strange behavior with time-series x-axis
I recently called plot(x,y) where x was an array of POSIXct timestamps, and was pleasantly surprised that it produced a nice plot right out of the box: z <- as.POSIXct(c("2006-10-26 08:00:00 EDT","2007-10-25 12:00:00 EDT")) x <- seq(z[1],z[2],len=100) y <- 1:100 plot(x,y,type="l") The X axis had nice labels, one tick mark every other month. (Plotting on
2009 Mar 30
1
Possible bug in summary.survfit - 'scale' argument ignored?
Hi all, Using: R version 2.8.1 Patched (2009-03-07 r48068) on OSX (10.5.6) with survival version: Version: 2.35-3 Date: 2009-02-10 I get the following using the first example in ?summary.survfit: > summary( survfit( Surv(futime, fustat)~1, data=ovarian)) Call: survfit(formula = Surv(futime, fustat) ~ 1, data = ovarian) time n.risk n.event survival
2006 Aug 17
1
putting the mark for censored time on 1-KM curve or competing risk curve
Hi All, I'm trying to figure out the cumulative incidence curve in R in some limited time. I found in package "cmprsk", the command "plot.cuminc" can get this curve. But I noticed that there is no mark for the censored time there, comparing with the KM curve by "plot.survfit". Here are my codes (attached is the data): ----------------
2012 Nov 27
4
Fitting and plotting a coxph with survfit, package(surv)
Hi Dear R-users I have a database with 18000 observations and 20 variables. I am running cox regression on five variables and trying to use survfit to plot the survival based on a specific variable without success. Lets say I have the following coxph: >library(survival) >fit <- coxph(Surv(futime, fustat) ~ age + rx, data = ovarian) >fit what I am trying to do is plot a survival
2011 Jul 14
1
glm() scale parameters and predicted Values
In glm() you can use the summary() function to recover the shape parameter (the reciprocal of the dispersion parameter). How do you recover the scale parameter? Also, in the given example, how I estimate and save the geometric mean of the predicted values? For a simple model you can use fitted() or predicted() functions. I will appreciate any help. ? ? ? #Call required R packages require(plyr)?
2009 Jan 19
1
further notes on model.frame issue
This is a follow-up on my note of Saturday. Let me start with two important clarifications - I think this would be a nice addition, but I've had exactly one use for it in the 15+ years of developing the survival package. - I have a work around for the current case. Prioritize accordingly. The ideal would be to change survexp as follows: fit <- survexp( ~ gender,
2011 Nov 07
2
Problem working with dates
Hello All, I've been reading books about R for awhile now and am in the process of replicating the SAS analyses from an old report. I want to be sure that I can do all the things I need to in R before using it in my daily work. So far, I've managed to read in all my data and have done some data manipulation. I'm having trouble with fixing an error in a date variable though, and was
2005 Dec 20
2
Time data
Dear All, I wonder how to compute the age from the date of birth and the date of examination. Suppose that have the following data: df <- as.data.frame(rbind(c(1,"10/08/1950","15/03/1998"), c(1,"10/08/1950","20/07/1998"), c(1,"10/08/1950","23/10/1998"))) names(df) <- c("ID", "date_birth",
2005 Dec 18
13
calculate age based on DoB
Hi, I wrote a little helper that calulates someone''s age based on his/her date of birth. def age(dob) diff = Date.today - dob age = (diff / 365.25).floor age.to_s end It works fine, but it''s not completely accurate as it just takes the average days in a year. It should be able to calculate this more accurately, right? I can''t work it out
2011 May 14
2
changing the day of the week in dates format
Dear all, I have a question related to the POSIXlt function in R. I have a set of dates and times, for exmaple: startx <- as.POSIXct("2011-01-01 00:00:00") finx <- as.POSIXct("2011-12-31 00:00:00") daysx<- seq(startx, finx, by="24 hours") I want to change the dates of all the days falling on a Saturday to the next working day (i.e. Monday). So I
2011 May 26
5
Survival: pyears and ratetable: expected events
Dear all, I am having a (really) hard time getting pyears to work together with a ratetable to give me the number of expected events (deaths). I have the following data: dos, date of surgery, as.Date dof, date of last follow-up, as.Date dos, date of surgery, as.Date sex, gender, as.factor (female,male) ev, event(death), 0= censored at time point dof, 1=death at time point dof Could someone
2003 Jun 30
1
date to age
I have files which have columns of data that look like this: DOB 9/27/1964 ... That is, dates in month/day/year format. When variables like DOB are read in, they are converted to factors. So, I wrote this to convert from date to age in years: age<-function(x) {as.numeric(Sys.time()-strptime(as.character(x),format="%m/%d/%Y"))/365.25} This isn't very precise or pretty, but it
2005 Mar 27
0
netcdf
Hi All, I'm very knew to R. I downloaded and am running it on my redhat so that I can use the clim.pact package. Everything is downloaded and installed correctly. When trying to read a netcdf file from the NCEP/NCAR reanalysis dataset using retrieve.nc I keep getting errors that the number of dimensions are wrong. If I use x.1 <- retrieve.nc("geopothgt.nc") I get the above