Difference between revisions of "OpasnetUtils/Dropall"

From Testiwiki
Jump to: navigation, search
m
m
Line 15: Line 15:
 
label="Initiate functions"
 
label="Initiate functions"
 
graphics="1"
 
graphics="1"
 +
showcode="1"
 
>
 
>
 
# DROPALL #####################################
 
# DROPALL #####################################

Revision as of 10:48, 15 June 2012



Description

dropall pudottaa data.framesta pois kaikki faktorien sellaiset levelit, joita ei käytetä.

Parameters

  • x = data.frame

Code

- Hide code

# DROPALL #####################################
## dropall pudottaa data.framesta pois kaikki faktorien sellaiset levelit, joita ei käytetä.
## parametrit: x = data.frame 

dropall <- function(x){
	isFac <- NULL
	for (i in 1:dim(x)[2]){
		isFac[i] = is.factor(x[ , i])
	}
	for (i in 1:length(isFac)){
		x[, i] <- x[, i][ , drop = TRUE]
	}
	return(x)
}

See also