R Error in strsplit() Function – non-character argument (2 Examples)

In this tutorial, I’ll illustrate how to deal with the “Error in strsplit : non-character argument” in R programming.

Creation of Example Data

my_data <- 1213141516                    # Example data in R
my_data                                  # Display example data in RStudio
# [1] 1213141516

Example 1: Replicating the Error Message in strsplit – non-character argument

strsplit(my_data,                        # Applying strsplit to numeric
         split = "1")
# Error in strsplit(my_data, split = "1") : non-character argument

Example 2: Solving the Error Message in strsplit – non-character argument

my_data_char <- as.character(my_data)    # Convert numeric to character
my_data_char                             # Display character string in RStudio
strsplit(my_data_char,                   # Applying strsplit to character
         split = "1")

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top