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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:03:44+00:00 2026-06-05T21:03:44+00:00

I have an excel csv with a date/time column and a value associated with

  • 0

I have an excel csv with a date/time column and a value associated with that date/time. I’m trying to write a script that will go through this format (see below), and find 1) the maximum value per day, and 2) the time on that day that the maximum occurs. Preferably R would return both values to me in a new dataframe.

The data looks something like this:

         V1    V2 V3
1  5/1/2012  3:00  1
2  5/1/2012  6:00  2
3  5/1/2012  9:00  5
4  5/1/2012 12:00  3
5  5/1/2012 15:00  6
6  5/1/2012 18:00  2
7  5/1/2012 21:00  1
8  5/2/2012  0:00  2
9  5/2/2012  3:00  3
10 5/2/2012  6:00  6
11 5/2/2012  9:00  4
12 5/2/2012 12:00  6
13 5/2/2012 15:00  7
14 5/2/2012 18:00  9
15 5/2/2012 21:00  1

So the function I’m envisioning would return:

1 5/1/2012 15:00 6
2 5/2/2012 18:00 9

Any ideas?

  • 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-05T21:03:48+00:00Added an answer on June 5, 2026 at 9:03 pm

    here you go:

    dat.str <- '         V1    V2 V3
    1  5/1/2012  3:00  1
    2  5/1/2012  6:00  2
    3  5/1/2012  9:00  5
    4  5/1/2012 12:00  3
    5  5/1/2012 15:00  6
    6  5/1/2012 18:00  2
    7  5/1/2012 21:00  1
    8  5/2/2012  0:00  2
    9  5/2/2012  3:00  3
    10 5/2/2012  6:00  6
    11 5/2/2012  9:00  4
    12 5/2/2012 12:00  6
    13 5/2/2012 15:00  7
    14 5/2/2012 18:00  9
    15 5/2/2012 21:00  1'
    
    dat <- read.table(textConnection(dat.str), row.names=1, header=TRUE)
    
    do.call(rbind, 
            by(dat, INDICES=dat$V1, FUN=function(x) tail(x[order(x$V3), ], 1)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that generates a csv file using the following code: header('Content-type:
I have a Excel CSV files with employee records in them. Something like this:
I have a time field of this format HH:MM:SS in many excel cells (when
I have an Excel (or CSV) file that contains the following flattened columns: ID,XPath,Required?,BaseType,Restrictions
Ok, so I have the following script that will export data from my database
i have this php to export date into a csv file: $link = mysql_connect($host,
I have a web page where it will input an excel/CSV file from the
I have an excel file that I converted to a CSV so it could
Basically my problem is this: I have a CSV excel file with info on
I have a fairly large Excel csv file that I need to add and

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.