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 7189313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:16:32+00:00 2026-05-28T19:16:32+00:00

I am a newbie in R, and I think I need done is do-able

  • 0

I am a newbie in R, and I think I need done is do-able with reshape, melt and cast functions. I did some reading but cannot figure out how to go about doing it.

I have a data frame like this:

)
server1, 01/01/2012, Memory, 27.200000, 27.490000, 28.560000, 29.300000
server1, 01/01/2012, disk , 2.330000, 22.380000, 7.580000, 2.440000
server1, 01/01/2012, CPU 0.470000, 36.500000, 12.230000, 0.350000
server1, 01/01/2012, interface 2.330000, 22.380000, 7.580000, 2.440000

I like to convert this data frame to something like this, so that R can easily read and graph this data:

server1, 01/01/2012:01:00, 27.200000, 2.330000,0.470000, 2.330000  
server1, 01/01/2012:02:00, 27.49, 22.38, 36.50, 22.38
server1, 01/01/2012:03:00, 28.56, 7.58, 12.23, 7.58
server1, 01/01/2012:04:00, 29.30, 2.44, 0.35, 2.44
  1. combining ExtractedDate with Hour1 (e.g. if the Heading says Hour1, the Exracted Date should be “01/01/2012 01:00”

  2. turn metrictype to header (header should be: put Hourly data in columns rather than rows.

can someone help me with this?

update=======

playing with melt and cast, I thing I am getting very close. I did these 3 commands:

 1. x <- data.frame(read.table("out.txt", sep=",", header=T))
 2. y <- melt(x, id=c("Hostname", "Date", "Met"))
 3. yy <- cast(y, Hostname + Date + variable ~ Mete)

my output looks like this:

     Hostname 

 1  server1  01/29/2012    Hour1       0.72       2.33     23.76
 2  server1  01/29/2012    Hour2       2.38       2.86     23.82
 3  server1  01/29/2012    Hour3       9.59       6.25     24.85
 4  server1  01/29/2012    Hour4      31.09      18.41     25.87
 5  server1  01/29/2012    Hour5       0.42       1.92     24.24
 6  server1  01/29/2012    Hour6       1.79       2.65     24.31

The problem I am facing now is that I have to combine Date and variable field. For example, 1st rows date field should be 01/29/2012 01:00, second row, 01/29/2012 02:00 so forth, if someone can help me with this, that would be awesome.

  • 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-05-28T19:16:33+00:00Added an answer on May 28, 2026 at 7:16 pm

    use something like gsub first:

    yy$variable <- as.integer(gsub('Hour', '', yy$variable))
    

    Then turn it into a POSIX time format:

    yy$variable <- paste(yy$variable, ‘:00:00’, sep=”)

    Convert your date to a date:

    yy$Date <- as.Date(yy$Date, format='%m/%d/%Y')
    

    Then mash it together:

    yy$date_time <- as.POSIXct(paste(yy$Date, yy$variable))
    

    I assume there is a pretty way using the zoo package, but I don’t know it well at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not think this is a duplicate. I have done some reading but
Okay, so I'm obviously a newbie, but I need some help passing a variable
Im a javascript newbie and would need some help with this simple thing... I
I think the question is a bit silly, but for a newbie startup building
I'm a multiprocessing newbie, I know something about threading but I need to increase
Some newbie questions about multi-threading in .NET which I think will help reinforce some
I think that this is a newbie type question but I have quite understood
I'm a newbie in Linq and C# and I'm going need some help. These
I don't think I'm missing anything. Then again I'm kind of a newbie. def
I'm a total newbie regarding to DLL. And I don't need to creat them

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.