|
|
@@ -14,8 +14,8 @@
|
|
|
sumWithNA<-function(df,var1='lesionmtv41',var2='metastasesmtv41',outVar='totalmtv41',valIfNA=0){
|
|
|
v1=df[,var1]
|
|
|
v2=df[,var2]
|
|
|
- v1[is.na(v1)]=valIfNA
|
|
|
- v2[is.na(v2)]=valIfNA
|
|
|
+ v1[base::is.na(v1)]=valIfNA
|
|
|
+ v2[base::is.na(v2)]=valIfNA
|
|
|
df[,outVar]=v1+v2
|
|
|
df
|
|
|
|
|
|
@@ -32,10 +32,27 @@ sumWithNA<-function(df,var1='lesionmtv41',var2='metastasesmtv41',outVar='totalmt
|
|
|
#' @export
|
|
|
|
|
|
mapNA<-function(df,var,valIfNA=0){
|
|
|
- df[is.na(df[,var]),var]=valIfNA
|
|
|
+ df[base::is.na(df[,var]),var]=valIfNA
|
|
|
df
|
|
|
}
|
|
|
|
|
|
+#' Remove entries with missing variables for selected variables
|
|
|
+#'
|
|
|
+#' @param x data frame
|
|
|
+#' @param vars vector of variable names as strings
|
|
|
+#'
|
|
|
+#' @return data frame with entries where vars were NA removed
|
|
|
+#'
|
|
|
+#' @export
|
|
|
+
|
|
|
+remove.NA<-function(x,vars){
|
|
|
+ for (v in vars){
|
|
|
+ x<-x[!base::is.na(x[,v]),]
|
|
|
+ }
|
|
|
+ x
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#' Map variable time OS status to status at cutoff
|
|
|
#'
|
|
|
#' @param df data frame
|
|
|
@@ -130,6 +147,6 @@ setEventTime<-function(df,duration='years_to_event',eventColumn='d_os',startColu
|
|
|
#' @export
|
|
|
|
|
|
convert.to.date<-function(x,var,format="%Y-%m-%d"){
|
|
|
- x[,var]<-as.Date(x[,var],format=format)
|
|
|
+ x[,var]<-base::as.Date(x[,var],format=format)
|
|
|
x
|
|
|
}
|