Skip to content
Prev 360745 / 398506 Next

Issue replacing dataset values from read data

1. It's not immediately clear why you need the line "temp <- subset(df, id
== myid)"

2. The objects described by "temp$age", temp$agesmoke, and temp$yrsquit are
all vectors. So temp.yrssmoke is also a vector. This means that when you
replace, it should be with "<- temp.yrssmoke[i]", where "i" is the (row)
 number you're looping over (note "temp" re-numbers rows to 1 through 6,
another reason to remove the "temp" line).

3. Ditto for " <- (temp$cigsdaytotal[i]/20)*(temp.yrssmoke[i]) "

Hope this helps!

Bill

W. Michels, Ph.D.
On Fri, May 6, 2016 at 3:19 PM, Chang, Emily <Emily.Chang2 at ucsf.edu> wrote: