nbaes
February 21, 2023, 12:36pm
1
Would anyone know why I am having trouble selecting certain columns in the function pivot_longer
?
Error :
Backtrace:
tidyr::pivot_longer(...)
tidyr:::pivot_longer.data.frame(...)
tidyr::pivot_longer_spec(...)
Run rlang::last_trace()
to see the full context.
rlang::last_trace()
<error/vctrs_error_ptype2>
Error in pivot_longer_spec()
:
! Can't combine cognitive_testing
and ethnic_racial_id
.
df :
code:
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 minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
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
system
Closed
March 14, 2023, 1:05pm
3
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.