OpasnetUtils/Dropall: Difference between revisions

From Opasnet
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 11: Line 11:


==Code==
==Code==
<rcode
name="answer"
label="Initiate functions"
graphics="1"
showcode="1"
>
# DROPALL #####################################
## dropall pudottaa data.framesta pois kaikki faktorien sellaiset levelit, joita ei käytetä.
## parametrit: x = data.frame


dropall <- function(x){
https://www.opasnet.org/svn/opasnet_utils/trunk/R/DropAll.r
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)
}
 
</rcode>


==See also==
==See also==

Latest revision as of 13:32, 16 August 2012



Description

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

Parameters

  • x = data.frame

Code

https://www.opasnet.org/svn/opasnet_utils/trunk/R/DropAll.r

See also