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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:41:44+00:00 2026-05-18T08:41:44+00:00

I have a dataframe called ants detailing multiple entries per site, looks like this:

  • 0

I have a dataframe called ants detailing multiple entries per site, looks like this:

  Site     Date     Time  Temp SpCond Salinity Depth Turbidity Chlorophyll
1   71 6/8/2010 14:50:35 14.32  49.88    32.66 0.397       0.0         1.3
2   71 6/8/2010 14:51:00 14.31  49.94    32.70 1.073       0.0         2.0
3   71 6/8/2010 14:51:16 14.32  49.95    32.71 1.034      -0.1         1.6
4   71 6/8/2010 14:51:29 14.31  49.96    32.71 1.030      -0.2         1.6
5   70 6/8/2010 14:53:55 14.30  50.04    32.77 1.002      -0.2         1.2
6   70 6/8/2010 14:54:09 14.30  50.03    32.77 0.993      -0.5         1.2

Sites have different numbers of entries, usually 3 but sometimes less or more. Where both date and site number match I would like to write a new dataframe with one entry per site detailing the average/mean readings for each parameter. I would like empty or “na” cells to be omitted from the calculation and subsequent dataframe.

I’m not sure if this is an apply function or a version of rowMeans maybe? Very stuck, any help much appreciated!

  • 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-18T08:41:45+00:00Added an answer on May 18, 2026 at 8:41 am

    Here is a complete new answer with a full log also covering your new specification:

    R> Lines <- "  Site     Date     Time  Temp SpCond Salinity Depth Turbidity Chlorophyll
    + 71 6/8/2010 14:50:35 14.32  49.88    32.66 0.397       0.0         1.3
    + 71 6/8/2010 14:51:00 14.31  49.94    32.70 1.073       0.0         2.0
    + 71 6/8/2010 14:51:16 14.32  49.95    32.71 1.034      -0.1         1.6
    + 71 6/8/2010 14:51:29 14.31  49.96    32.71 1.030      -0.2         1.6
    + 70 6/8/2010 14:53:55 14.30  50.04    32.77 1.002      -0.2         1.2
    + 70 6/8/2010 14:54:09 14.30  50.03    32.77 0.993      -0.5         1.2
    + "
    R> con <- textConnection(Lines)
    R> df <- read.table(con, sep="", header=TRUE, stringsAsFactors=FALSE)
    R> close(con)
    R> df$pt <- as.POSIXct(strptime(paste(df$Date, df$Time), "%m/%d/%Y %H:%M:%S"))
    R> library(plyr)
    R> newdf <- ddply(df, .(Site,Date), function(x) mean(x[,-(1:3)], na.rm=TRUE))
    R> newdf$pt <- as.POSIXct(newdf$pt, origin="1970-01-01")
    R> newdf
      Site     Date  Temp SpCond Salinity  Depth Turbidity Chlorophyll                  pt
    1   70 6/8/2010 14.30  50.03    32.77 0.9975    -0.350       1.200 2010-06-08 20:54:02
    2   71 6/8/2010 14.32  49.93    32.70 0.8835    -0.075       1.625 2010-06-08 20:51:05
    R> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataframe foo looking like this Date Return 1998-01-01 0.02 1998-01-02 0.04
If I have the following dataframe called result > result Name CV LCB UCB
Say I have an R list like this: > summary(data.list) Length Class Mode aug9104AP
I have a dataframe and would like to calculate the correlation (with Spearman, data
I have a snippet to create a 'Like' button for our news site: <iframe
I would like to transform/modify the content of dataframe. Basically I have a dataframe
In R I am trying to delete rows within a dataframe (ants) which have
I have dataframe (return.monthly) of the form Date Return 2001-09-1 0.0404775 2001-10-1 -0.01771575 2001-11-1
i have a data frame that contains a data like this : V1 V2
Have just started using Google Chrome , and noticed in parts of our site,

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.