0

We extracted a column from our dataframe(called "DT") that we had to test for reliability by using the Cronbach alpha.

The code we used to extract the data was:

Mydata_age <- DT %>% select(as.numeric(as.character(DT$Q7...23)))

We did this because at first "DT$Q7...23" did not give us a numeric value, even though it contained ages of participants in a survey we made and used to extract our data from.

However, when we ran the code it keeps saying

Can't subset columns past the end
There are only 24 columns

We expected Mydata_age to work and then to run Alpha(Mydata_age) to give us a value.

  • Do the transformation within `mutate/transmute`. Also, to select columns if the name is nonstandard, use backquotes around it. i.e. `DT %>% transmute(`Q7...23` = `as.numeric(as.character(`Q7...23`)))` – akrun Dec 09 '22 at 16:50
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Dec 09 '22 at 19:00

0 Answers0