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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:56:19+00:00 2026-05-25T12:56:19+00:00

here is the function which is working fine, but giving the output in an

  • 0

here is the function which is working fine, but giving the output in an output which I don’t want.

frequencies <- {}

for (k in (1:4))
{   
    interval <- (t(max_period_set[k]))

    intervals <- round(quantile(interval,c(0,0.05,0.15,0.25,0.35,0.45,0.55,0.65,0.75,0.85,0.95,1.0)))
    frequency <- {}
    for (i in (2:length(intervals)))
    {       
        count = 0;      
        for (r in (1:length(interval)))
        {
            if (r == length(interval))
            {
                if (interval[r] >= intervals[i-1] && interval[r] <= intervals[i])
                {
                    count = count + 1
                }
            }
            else
            { 
                if (interval[r] >= intervals[i-1] && interval[r] < intervals[i])
                {
                    count = count + 1
                }
            }
        }   
        frequency <- c(frequency,count)
    }
    frequencies[[length(frequencies)+1]] <- frequency
}

The output is as follows:

> frequencies
[[1]]
 [1] 2 6 5 4 5 4 6 5 5 5 3

[[2]]
 [1] 1 7 5 4 5 4 5 6 5 5 3

[[3]]
 [1] 3 5 5 4 5 4 6 5 5 5 3

[[4]]
 [1] 3 5 5 4 4 6 5 5 5 5 3

I would like to have it in a format as follows:

[[],[],[],[]] which is a list of list whose first element I can access like frequencies[1] to get the first list, etc…

If it is not possible, how can I access the first list values in my current format? frequencies[1] does not give me the first list values back.

Thanks for your help!

Guys an another question:

now I can access the data but r is representing the last line in different format:

[[1]]
 [1] 1.00 0.96 0.84 0.74 0.66 0.56 0.48 0.36 0.26 0.16 0.06 0.00

[[2]]
 [1] 1.00 0.98 0.84 0.74 0.66 0.56 0.48 0.38 0.26 0.16 0.06 0.00

[[3]]
 [1] 1.00 0.94 0.84 0.74 0.66 0.56 0.48 0.36 0.26 0.16 0.06 0.00

[[4]]
 [1] 1.000000e+00 9.400000e-01 8.400000e-01 7.400000e-01 6.600000e-01 5.800000e-01 4.600000e-01 3.600000e-01 2.600000e-01 1.600000e-01 6.000000e-02 1.110223e-16

Why is it happening with the accuracy? the first three lines are as it should be but the last line is odd, the numbers were not infractional numbers, so it can be represented as a number with its accuracy of 2 after comma digits.

  • 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-25T12:56:19+00:00Added an answer on May 25, 2026 at 12:56 pm

    frequencies is a list, so you need

     frequencies[[1]]
    

    to access the first element. If list were named, you could also index by element name.

    Lists are the most general data structure, and the only one that can

    • be nested: lists within lists within …
    • be ragged: does not require rectangular dimensions

    so you should try to overcome initial aversion to the fact that it is different. These are very powerful data structures, and are use a lot behind the scenes.

    Edit: Also, a number of base functions as well as add-on packages can post-process lists. It starts with something basic like do.call(), goes to lapply and ends all the over at the plyr packages. Keep reading — there are many ways to skin the same cat, some better than others.

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

Sidebar

Related Questions

I am using jQuery autocomplete which is working fine with existing element but not
I have this code, which is working fine in FireFox, chrome and IE8 but
I'm trying to parallelize a convolution function in C. Here's the original function which
I have this mysql query using PHP and first part is working fine, but
I don't know why but this code is not working ? Why would it
We have few projects, which are compiling my makefile. These make file working fine
I have a cfselect which is working fine. I have an onclick event to
I'm trying to read .doc .docx file in php. All is working fine. But
I have a piece of jquery which is working fine on firefox and ie
I have this banner rotator which is working fine except for one problem... This

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.