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

  • SEARCH
  • Home
  • 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 7780379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:52:41+00:00 2026-06-01T18:52:41+00:00

Dear All I am working with a file which has few years data and

  • 0

Dear All I am working with a file which has few years data and I am trying to create an aditional coloumn that reads the year and month info from the date coloumn (e.g. 01/01/1997 12:00) and create a new coloumn with month and year together(e.g. Jan-97).

I am not sure how to proceed with this but what I am trying to code is the coloumn with name “new_date” in the following picture:

enter image description here

My sample data:

Data <-
structure(list(date = structure(c(1L, 4L, 7L, 2L, 5L, 8L, 3L, 
6L, 9L), .Label = c("01/01/1997 12:00", "01/01/1998 15:00", "01/01/1999 18:00", 
"01/02/1997 13:00", "01/02/1998 16:00", "01/02/1999 19:00", "01/03/1997 14:00", 
"01/03/1998 17:00", "01/03/1999 19:00"), class = "factor"), value = c(29L, 
31L, 42L, 42L, 52L, 61L, 57L, 55L, 56L)), .Names = c("date", 
"value"), row.names = c(NA, -9L), class = "data.frame")

I would really appreciate if you could advise me about how should I proceed with this.

  • 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-01T18:52:43+00:00Added an answer on June 1, 2026 at 6:52 pm

    take a look at ?strptime for the correct formatting.

    first make your date column a date:

    dat$date <- as.POSIXct(dat$date, format='%d/%m/%Y %H:%M')
    

    then make your new column with the formatting you want:

    dat$pretty.date <- format(dat$date, format='%b-%y')
    
    > dat$pretty.date
    [1] "Jan-97" "Feb-97" "Mar-97" "Jan-98" "Feb-98" "Mar-98" "Jan-99" "Feb-99" "Mar-99"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

dear all. i have a lot of data in my database. after that i
Dear all, I have a select query that currently produces the following results: DoctorName
dear all, i'll take some data from the database. and join two tables.the code
Dear all devexpress winform gurus:) My way is simple. First, i create a bindinglist:
dear all..i've a textfield, it using barcode scanner for input data..after scan it shows
Dear All, I am trying to parse the following HTML fragment, and I would
Dear all, I am writing a python program that is retrieving edifact log messages
dear all i want to know how to submit asp.net form data using jquery
Dear all, I am working on flex3 and want to update my application by
dear all.can you tell me how to collecting this data in mysql: item colour

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.