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

The Archive Base Latest Questions

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

I have a very big data frame consisting of data like this: PENR ANFDAT

  • 0

I have a very big data frame consisting of data like this:

  PENR     ANFDAT     ENDDAT
1 1110 1990-02-01 1998-10-29
2 1981 1998-02-19 1998-02-20
3 6317 1994-11-01 1999-06-30
4 2039 1998-12-01 1999-04-30

(get it from here)

df <- structure(list(PENR = c(1110L, 1981L, 6317L, 2039L), ANFDAT = structure(c(7336, 10276, 9070, 10561), class = "Date"), ENDDAT = structure(c(10528, 10277, 10772, 10711), class = "Date")), .Names = c("PENR", "ANFDAT", "ENDDAT"), row.names = c(1L, 2L, 3L, 4L), class = "data.frame")

ANFDAT stands for the beginning of a certain status, ENDDAT stends for the termination of this status

I want to display this data as a bar chart. Each bar should stand for a date. the height of each bar should represent the number of records (PENR) having the status on this date.

As the data frame is very big I look for an efficient way to achieve this.

[EDIT]

Seems like my question is misleading. Here’s what I try to do:

  1. Generate a data frame for each date from min(df$ANFDAT) to max(df$ENDDAT). This can be done easily with

    df1 <- data.frame(DATE = seq(min(df$ANFDAT), max(df$ENDDAT), by = "day"))
    
  2. For each row in df1$DATE, count the number of records in df that have ANFDAT >= DATE and ENDDAT <= DATE. Store the results in df1$RECORDS
  3. Generate a barplot out of df1. This probably can be done like that (untested)

    df2 <- df1$RECORDS
    row.names(df2) <- df1$DATE
    barplot(df2$RECORDS)
    

My problem is to find an efficient way to do #2

  • 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-15T13:36:39+00:00Added an answer on June 15, 2026 at 1:36 pm

    You could use sapply over the unique dates to count the number of records.

    The whole procedure:

    DATE <- seq.int(min(df$ANFDAT), max(df$ENDDAT), by = "day")
    
    df1 <- data.frame(RECORDS = sapply(DATE, function(x)
                                    sum(df[["ANFDAT"]] <= x &  df[["ENDDAT"]] >= x)))
    
    rownames(df1) <- DATE
    barplot(df1$RECORDS)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a very big data frame((35000 line) but i want to get specific
I have a database with a name column having data like 'Very big News'
I have this data which can be very big in size, this could be
I have very very big html page/data. I need to fetch data under h1
I have an element which may contain very big amounts of data, but I
I have got very big problem because I would like to get more information
I'm dealing with very big data in matlab and used to store this data
I have a very big table of measurement data in MySQL and I need
I have a data.table that is not very big (2 GB) but for some
I have some very big delimited data files and I want to process only

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.