Re: [R] dataframe columns class

2016-12-18 Thread Jeff Newmiller
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

Re: [R] dataframe columns class

2016-12-18 Thread Ista Zahn
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"

[R] dataframe columns class

2016-12-18 Thread Cleber N.Borges via R-help
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