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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:38:33+00:00 2026-06-15T05:38:33+00:00

I have some daily time-series data that i need to extract the ‘week day

  • 0

I have some daily time-series data that i need to extract the ‘week day percent’ relative to the week mean. For example, if the first week has mean = 100 and the Sunday value for this week is 20, then sunday becomes 0.2.

Here’s some random data:

set.seed(0)
y = rnorm(1705)
date = seq(as.Date('2008-01-01'), by = 'day', length = length(y))
data.df = data.frame(y, date)

I need a new column called pecent, which is the value explained above. I tried to add some
columns then use tapply, but failed. Appreciate any help!

  • 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-15T05:38:34+00:00Added an answer on June 15, 2026 at 5:38 am

    First create a week variable using format. Then use ddply and transform.

    library(plyr)
    data.df$week <- format(data.df$date,'%W %Y') #week begins with Monday
    data.df <- ddply(data.df,~week,transform,percent=y/mean(y))
    head(data.df)
    
               y       date    week    percent
    1  1.2629543 2008-01-01 00 2008  3.1395415
    2 -0.3262334 2008-01-02 00 2008 -0.8109741
    3  1.3297993 2008-01-03 00 2008  3.3057095
    4  1.2724293 2008-01-04 00 2008  3.1630952
    5  0.4146414 2008-01-05 00 2008  1.0307451
    6 -1.5399500 2008-01-06 00 2008 -3.8281172
    

    Note that week 00 usually is not a full week as is the last week of the year. Merge last and first weeks of subsequent years if that matters.

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

Sidebar

Related Questions

In my Android app, I have some data that needs to be synced daily
I have some data loaded as a np.ndarray and need to convert it to
I have some arbitrary pixel data that I want to save as a PNG.
I have a daily cron job that grabs 10 users at a time and
I have a zoo object in R that has daily data and is missing
I am using R for some statistical analysis of time series. I have tried
Assume you have a table with a stock time series on a daily basis.
I have created a system that sends some information by SMS daily to our
I have a Day object which contains some statistics and is updated daily. Here's
I have some daily analytics-style records that track usage on my site, and they

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.