Skip to content
Advertisement

R : x comparison (1) is possible only for atomic and list types

I am using R. In a previous post (R: Loop Producing the Following Error: Argument 1 must have names), I learned how to make a function (“create_data”) for my code.

Now, I am trying to modify this function.

First, I create some data to be used for this example:

Here is the modified version of the function:

The error results when I try to call the function:

I have a feeling that maybe the error is occurring over here:

I tried to replace this “select” with a non-dplyr version:

But this also producing an error:

Can someone please show me what I am doing wrong?

Thanks

Advertisement

Answer

You are selecting only 3 columns here which does not include cat column hence you get the error.

Instead you can first filter and then select.

Same should be applied for b_table and c_table.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement