From 512ac511a375561befd6c02bb944f520b7d8dd2b Mon Sep 17 00:00:00 2001 From: agdamsbo Date: Tue, 9 Oct 2018 14:27:07 +0200 Subject: [PATCH] resolved function overlap --- R/col_fact.R | 14 +++++++------- R/col_num.R | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/col_fact.R b/R/col_fact.R index 0bab760..1d31275 100644 --- a/R/col_fact.R +++ b/R/col_fact.R @@ -14,27 +14,27 @@ col_fact<-function(string,data,levels=NULL,labels=NULL){ ## Defining factors for columns containing string (can be vector of multiple strings), based on dplyr. ## Factoring several columns with same levels or labels, these can be provided. - + require(dplyr) d<-data s<-string n<-c() - + for(i in 1:length(s)){ - n<-c(n,names(select(d,contains(s[i])))) + n<-c(n,names(dplyr::select(d,dplyr::contains(s[i])))) } if (!is.null(levels)){ for(i in 1:length(n)) { d[,n[i]]<-factor(d[,n[i]],levels=levels)}} - - if (!is.null(labels)){ + + if (!is.null(labels)){ for(i in 1:length(n)) { d[,n[i]]<-factor(d[,n[i]],labels=labels) }} - else + else for(i in 1:length(n)) { d[,n[i]]<-factor(d[,n[i]])} - + return(d) } diff --git a/R/col_num.R b/R/col_num.R index 9aa4914..02dc6cd 100644 --- a/R/col_num.R +++ b/R/col_num.R @@ -15,11 +15,11 @@ col_num<-function(string,data){ d<-data s<-string n<-c() - + for(i in 1:length(s)){ - n<-c(n,names(select(d,contains(s[i])))) + n<-c(n,names(dplyr::select(d,dplyr::contains(s[i])))) } - + for(i in 1:length(n)) { d[,n[i]]<-as.numeric(d[,n[i]]) }