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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:50:32+00:00 2026-06-01T19:50:32+00:00

I am trying to figure out a method to increase the number of elements

  • 0

I am trying to figure out a method to increase the number of elements of vectors, in order to remove the angular effect visible when I plot the values of these vectors. For instance, let’s say I got two vectors containing 10 elements each:

a = c(4,2,10,5,3,4,8,9,6,2)
b = seq(0,4.5, by=0.5)

They are subject to data smoothing, but I would like to increase their “resolution” to obtain more prediction points than 10 (its length). So, in other words, take the vector a and double (for example) its number of elements, while keeping its consistency. The resulting vector should be something like:

a = c(4,3,2,6,10,7,5,4,3,4,6,8,8.5,9,7.5,6,4,2,2)

Of course, in this particular case, I can easily compute the average of the elements pair-wise. But I would like to have a generalized method for an arbitrary length. I have tried with:

seq(a[1],a[10], length.out=20)

but of course this does not do the job as only the first and last element of the vector are taken in consideration. It is suitable for the second vector b though (which contains the abscissa values).
Any help would be appreciated. Thanks.
Marius.

  • 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-01T19:50:33+00:00Added an answer on June 1, 2026 at 7:50 pm

    Do you just want linear interpolation based on the b sequence?

     f <- approxfun(b, a)
     f(seq(b[1], b[length(b)], length = 20))
     [1] 4.000000 3.052632 2.105263 5.368421 9.157895 8.157895 5.789474 4.368421 3.421053 3.263158 3.736842 4.842105 6.736842 8.157895 8.631579 8.684211 7.263158 5.789474
     [19] 3.894737 2.000000
    

    See ?approx for other options and its See also for other forms of interpolation, also ?round for rounding out the values in various ways.

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

Sidebar

Related Questions

I am trying to figure out why my $.getJSON method does not seem to
I’m trying to figure out whether FormsAuthentication.RedirectFromLoginPage (called inside method M() ), performs redirection
I'm trying to figure out if the boost::multi_array constructor or resize method can throw
I'm trying to figure out how to get the value from a method in
I'm trying to figure out why, when I give large a large number to
I'm trying to figure out the best method of getting/displaying the shortest distance between
I've been trying figure out how to add a handler to a method using
I'm trying to figure out what's the best method to do the following: Let's
I am trying to figure out how to catch any method called on an
I'm stuck at the moment trying to figure out a method of inserting into

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.