mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-22 11:50:23 +01:00
resolved function overlap
This commit is contained in:
parent
800b4e8199
commit
512ac511a3
14
R/col_fact.R
14
R/col_fact.R
@ -14,27 +14,27 @@
|
|||||||
col_fact<-function(string,data,levels=NULL,labels=NULL){
|
col_fact<-function(string,data,levels=NULL,labels=NULL){
|
||||||
## Defining factors for columns containing string (can be vector of multiple strings), based on dplyr.
|
## 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.
|
## Factoring several columns with same levels or labels, these can be provided.
|
||||||
|
|
||||||
require(dplyr)
|
require(dplyr)
|
||||||
d<-data
|
d<-data
|
||||||
s<-string
|
s<-string
|
||||||
n<-c()
|
n<-c()
|
||||||
|
|
||||||
for(i in 1:length(s)){
|
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)){
|
if (!is.null(levels)){
|
||||||
for(i in 1:length(n)) {
|
for(i in 1:length(n)) {
|
||||||
d[,n[i]]<-factor(d[,n[i]],levels=levels)}}
|
d[,n[i]]<-factor(d[,n[i]],levels=levels)}}
|
||||||
|
|
||||||
if (!is.null(labels)){
|
if (!is.null(labels)){
|
||||||
for(i in 1:length(n)) {
|
for(i in 1:length(n)) {
|
||||||
d[,n[i]]<-factor(d[,n[i]],labels=labels)
|
d[,n[i]]<-factor(d[,n[i]],labels=labels)
|
||||||
}}
|
}}
|
||||||
else
|
else
|
||||||
for(i in 1:length(n)) {
|
for(i in 1:length(n)) {
|
||||||
d[,n[i]]<-factor(d[,n[i]])}
|
d[,n[i]]<-factor(d[,n[i]])}
|
||||||
|
|
||||||
return(d)
|
return(d)
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ col_num<-function(string,data){
|
|||||||
d<-data
|
d<-data
|
||||||
s<-string
|
s<-string
|
||||||
n<-c()
|
n<-c()
|
||||||
|
|
||||||
for(i in 1:length(s)){
|
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)) {
|
for(i in 1:length(n)) {
|
||||||
d[,n[i]]<-as.numeric(d[,n[i]])
|
d[,n[i]]<-as.numeric(d[,n[i]])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user