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 t
Hi Emily,
I haven't tested this exhaustively, but it seems to work:
df<-data.frame(id=2001:3300,yrssmoke=sample(1:40,1300,TRUE),
cigsdaytotal=sample(1:60,1300,TRUE),yrsquit=sample(1:20,1300,TRUE))
dfNA<-sapply(df$id,"%in%",c(2165,2534,2553,2611,2983,3233))
# create your NA values
df[dfNA,c("yrsqu
Dear all,
I am reading a modest dataset (2297 x 644) with specific values I want to
change. The code is inelegant but looks like this:
df <- read.csv("mydata.csv", header = TRUE, stringsAsFactors = FALSE)
# yrsquit, packyrs missing for following IDs. Manually change.
for(myid in c(2165, 2534, 2
3 matches
Mail list logo