error using pivot_longer

Would anyone know why I am having trouble selecting certain columns in the function pivot_longer?


  1. tidyr::pivot_longer(...)
  3. tidyr::pivot_longer_spec(...)
    Run rlang::last_trace() to see the full context.

Error in pivot_longer_spec():
! Can't combine cognitive_testing and ethnic_racial_id .



df_long <- pivot_longer(df, cols = c(cognitive_testing, person_perception, sexuality, cell_culture, multicultural_counselling, sex_and_gender, 
                                     individualism_collectivism, stress_and_conflict, child_development , organizational_culture , body_image,
                                     construct_invariance, miscellaneous, substance_use, mental_health, consumer_behaviour, ethnic_racial_id,
                                     the_self, depth_psychology, identity, marginalised_identities, culture_theory, education, health_service_access,
                                     emotion_concepts), values_to = "index", names_to = "topics")

I think we need a see your code and some sample data.

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.

A screenshot of the data is pretty close to useless

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.