Displaying 2 results from an estimated 2 matches for "newdata3".
Did you mean:
newdata
2012 Sep 24
0
stop on rows where !is.na(mydata$ti_all)
..." & !is.na(subdata$ti_all))
new_out_c = ifelse(new_out_c == 0, NA, new_out_c)
new_cma_c = ifelse(new_cma_c == 0, NA, new_cma_c)
return(c(newname, NA, NA, NA, new_out_c, new_cma_c, new_c_n, NA))
}
})
# recombine and sort
colnames(newrows2) = colnames(mydata3)
newdata3 = rbind(mydata3, newrows2)
newdata3 = newdata3[order(newdata3$id), ]
identical(newdata3, newdata2)
identical(newdata2, newdata)
dim(mydata)
dim(newdata)
dim(newdata2)
dim(newdata3)
2024 Nov 27
4
R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments
Check out the dplyr package, specifically the mutate function.
# Create new column based on existing column value
df <- df %>% mutate(FirstDay = if(ID = 2, 5))
df
Repeat as needed to capture all of the day/firstday combinations you want to account for.
Like everything else in R, there are probably at least a dozen other ways to do this, between base R and all of the library packages