Re: [R] problem with using apply for dataframe

2012-07-24 Thread Marion Wenty
Jessica, thank you for your reply. Hi Eik, thank you VERY for your reply and thorough explanation! I hadn't understood what arrays are and after receiving your mail I read more on arrays (and data types, modes, classes etc in general) (and understood more than a few month ago) and understood thi

Re: [R] problem with using apply for dataframe

2012-07-19 Thread Eik Vettorazzi
Hi Marion, as stated in the help file ?apply coerces a data.frame object into an array. Since an array has only one type of data, this coercion turns all your variables into strings (because this data type can hold all information given without loss). If it happens that your data.frame consists on

Re: [R] problem with using apply for dataframe

2012-07-19 Thread Jessica Streicher
apply(mydataframe,2,function(x){ print(x);is.factor(x)}) [1] "1" "2" "3" "4" [1] "16.99" "10.34" "21.01" "23.68" [1] "1.01" "1.66" "3.50" "3.31" [1] "Male" "Male" "Male" "Female" X total_billtipsex FALSE FALSE FALSE FALSE > sapply(mydataframe,fu

[R] problem with using apply for dataframe

2012-07-19 Thread Marion Wenty
Dear people, I am including an example of a dataframe: mydataframe<-data.frame(X=c(1:4),total_bill=c(16.99,10.34,21.01,23.68),tip=c(1.01,1.66,3.50,3.31),sex=c("Male","Male","Male","Female")) When I use the sapply function getting the information about the factors works: sapply(mydataframe,funct