Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:01:35+00:00 2026-06-17T23:01:35+00:00

I read many posts on splitting strings in R. However, I am running into

  • 0

I read many posts on splitting strings in R. However, I am running into an error which I think is due to the way the variables were read into R i.e., space after the date in some cases because the ID is shorter. I am trying to split the character variable “VESSELID” into 2 new variables: “vesselID” and “DATE”. Below is a subset of my dataset.

> dput(df)
structure(list(SETID = c(24153L, 24187L, 24215L, 31990L, 31990L, 
31995L, 31995L, 31995L, 31996L, 31996L, 31996L, 31997L, 31997L, 
32002L, 32002L, 32002L, 32002L, 32003L, 32003L, 32003L), VESSELID = c("6830 2002/08/13  ", 
"6830 2002/08/12  ", "6830 2002/08/15  ", "105372 2002/08/23", 
"105372 2002/08/23", "104234 2002/07/20", "104234 2002/07/20", 
"104234 2002/07/20", "104234 2002/07/21", "104234 2002/07/21", 
"104234 2002/07/21", "104234 2002/07/22", "104234 2002/07/22", 
"5744 2002/08/14  ", "5744 2002/08/14  ", "5744 2002/08/14  ", 
"5744 2002/08/14  ", "5744 2002/08/13  ", "5744 2002/08/13  ", 
"5744 2002/08/13  ")), .Names = c("SETID", "VESSELID"), row.names = c(1L, 
2L, 3L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 24L, 25L, 26L), class = "data.frame")

I did try the following:

library(reshape2)
test <- data.frame(df, colsplit(df$VESSELID, split= " ",names=c("vesselID","DATE")))

However, I get this error message:

Error in colsplit(log21$VESSELID, split = " ", names = c("vesselID", "DATE")) : 
      unused argument(s) (split = " ")

The split command doesn’t seem to be able to work properly. I don’t know how to fix my character string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:01:37+00:00Added an answer on June 17, 2026 at 11:01 pm

    The argument name is not split, it is pattern :

    test <- data.frame(df, colsplit(df$VESSELID, pattern = " ",names=c("vesselID","DATE")))
    

    gives :

       SETID          VESSELID vesselID         DATE
    1  24153 6830 2002/08/13       6830 2002/08/13  
    2  24187 6830 2002/08/12       6830 2002/08/12  
    3  24215 6830 2002/08/15       6830 2002/08/15  
    10 31990 105372 2002/08/23   105372   2002/08/23
    11 31990 105372 2002/08/23   105372   2002/08/23
    12 31995 104234 2002/07/20   104234   2002/07/20
    13 31995 104234 2002/07/20   104234   2002/07/20
    14 31995 104234 2002/07/20   104234   2002/07/20
    15 31996 104234 2002/07/21   104234   2002/07/21
    16 31996 104234 2002/07/21   104234   2002/07/21
    17 31996 104234 2002/07/21   104234   2002/07/21
    18 31997 104234 2002/07/22   104234   2002/07/22
    19 31997 104234 2002/07/22   104234   2002/07/22
    20 32002 5744 2002/08/14       5744 2002/08/14  
    21 32002 5744 2002/08/14       5744 2002/08/14  
    22 32002 5744 2002/08/14       5744 2002/08/14  
    23 32002 5744 2002/08/14       5744 2002/08/14  
    24 32003 5744 2002/08/13       5744 2002/08/13  
    25 32003 5744 2002/08/13       5744 2002/08/13  
    26 32003 5744 2002/08/13       5744 2002/08/13  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to convert an NSDate into Unix timestamp? I've read many posts which do
I've read many posts about doing Rails nested forms, which I think I understand.
I read many posts regarding the same error message on SO, but none of
I read many posts on customizing color of selected tabbar item which is actually
I read many posts about this problem like [this link][1] and one solution is
I've read many posts about this but still settimeout doesn't work. I suspect it's
I have read many posts regarding deserialization of nullable fields but have not run
I've read many posts about this issue but I never got this to work.
OK I have read many posts regarding Dual Licensing using MIT and GPL licenses.
I've read many posts on the same topic and tried all the given solutions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.