Reputation: 1101
I have a data frame with logical vectors and numeric. I was working on a solution to count the number of logical vectors when for some reason the is.logical
function didn't working for me when applied to vectors. Any suggestions/alternatives?
apply(X = df1, MARGIN = 2, FUN = is.logical)
Upvotes: 1
Views: 207
Reputation: 81693
If your data frame contains numeric columns too, you should not use apply
for this task since the data frame is converted to a numeric matrix. Hence, no column is numeric. You can use sapply
instead.
sapply(df1, is.logical)
Upvotes: 3