0

I have a dataframe that consists of some numeric and some non numeric columns

I tried to pipe only the numeric columns into a shapiro wilk test to see what statistical test to perform on them but I can't get it to work

CRF %>% select_if(is.numeric) %>% shapiro.test()

Returns

Error in shapiro.test(.) : is.numeric(x) is not TRUE

I think it is because at the end I am still passing a list. But when I try to deconstruct it with unlist or to just run lapply on it still won't work.

My end goal is a vector containing all the names of all the values that are non-normal according to the shapiro wilk test so I can pass it later on into the function doing the statistical analysis.

Any ideas?

Thanks

1 Answer 1

1

Do you want to apply shapiro.test to each column separately? You can try map_if

purrr::map_if(CRF, is.numeric, shapiro.test)

Or in base R using lapply :

lapply(CRF[sapply(CRF, is.numeric)], shapiro.test)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.