Problems with Unite(), etc functions when columns have characters

So for my project I'm mostly using box and mosaic plots since all of my data is categorical.
My base data looks something like this:

I've tried using unite

ComprrJAcc <- unite(Comprr$Japanese, Comprr$Accuracy)

but it returns an error message that I cannot combine Japanese and Accuracy due to them not being numbers.

Error in UseMethod("unite_") : 
  no applicable method for 'unite_' applied to an object of class "character"

Is there a way to use mutate, transmute, or any other such prompt to create or merge columns are not numbers, or even possibly to make merges of columns where one contains numbers and the other contains characters?

Ideally I am trying to create a new column named JAcc (Japanese Accuracy) that would have entries like: NoCorrect, YesIncorrect, as well as one which lets me combine Participant number with Accuracy so I can plot Participant Accuracy versus other factors more easily.

On a related note, is it possible to run summarizing or "math" commands on cells that have characters instead of numbers, for example to find what percentage of cells in a column have a certain exact match?

Hi @cupricfae. The first argument of unite should be an dataframe or tibble. But you pass the character vector to it, so it raises error. Try the following code by replacing your data frame name.

ComprrJAcc  <- unite(yourDataFrameName, JAcc,  Japanese, Accuracy, sep = "")
1 Like

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