The apply function operates on arrays, so your data frame is being converted to
an array (matrix) before doing its thing. So use lapply or one of its
variants.
--
Sent from my phone. Please excuse my brevity.
On December 18, 2016 9:07:52 AM PST, "Cleber N.Borges via R-help"
wrote:
>Why colu
Read ?apply and you shall be be enlightened.
--Ista
On Dec 18, 2016 12:09 PM, "Cleber N.Borges via R-help"
wrote:
> Why columns classes are function dependents?
> Like this example:
>
> > for( i in 1:5 ) print( class( iris[,i] ) )
> [1] "numeric"
> [1] "numeric"
> [1] "numeric"
> [1] "numeric"
Why columns classes are function dependents?
Like this example:
> for( i in 1:5 ) print( class( iris[,i] ) )
[1] "numeric"
[1] "numeric"
[1] "numeric"
[1] "numeric"
[1] "factor"
>
> apply( iris, 2, class )
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
"character" "character" "cha
3 matches
Mail list logo