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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:16:33+00:00 2026-06-18T02:16:33+00:00

If I want to number all elements in two vectors, vector 1 gets all

  • 0

If I want to number all elements in two vectors, vector 1 gets all odd bumbers and vector 2 gets all even numbers, I can do this assuming the vectors are of length 10.

seq(1, 10, by=2)
[1] 1 3 5 7 9

seq(2, 11, by=2)
[1]  2  4  6  8 10

but if my vector has only one element I will run into problems:

 seq(2)
[1] 1 2

so I use:

seq_along(2)
[1] 1

BUT I cant use by= in seq_long(). How do i get the reliability of seq_along with the functionality of seq()?


This example might clear things.

Imagine I ahve two lists:

list1 <- list(4)
list2 <- list(4)

list1 must get even names along the element of the list.
list2 must get odd names along the element of the list.

I dont know how long the list elements will be.

seq_along(list1[[1]]) # this will know to only give one name but I cant make it even

seq(list2[[1]]) # this know to give 1 name
#and
seq(2, list1[[1]], by=2) # this gives me even but too nay names
  • 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-18T02:16:34+00:00Added an answer on June 18, 2026 at 2:16 am

    Here’s a function that adds a ‘by’ argument to seq_along:

    seq_along_by = function(x, by=1L, from = 1L) (seq_along(x) - 1L) * by + from
    

    and some test cases

    > seq_along_by(integer(), 2L)
    integer(0)
    > seq_along_by(1, 2L)
    [1] 1
    > seq_along_by(1:4, 2L)
    [1] 1 3 5 7
    > seq_along_by(1:4, 2.2)
    [1] 1.0 3.2 5.4 7.6
    > seq_along_by(1:4, -2.2)
    [1]  1.0 -1.2 -3.4 -5.6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to print all the prime numbers between two numbers. This is my
All I want is a pragmatic random number generator in C# so I can
i want to match for all /table[number] so strings like /table[1] and /table are
I want to convert all numbers with 6 digits to the word million. like
I want to keep only numbers and remove all characters from a variable. For
I have a string which contains only numbers. Now I want to remove all
Basically i got this for loop and i want the number inputed (eg. 123)
I have four std::vector containers that all might (or might not) contain elements. I
If I want to find all possible sums from two lists list1 and list2
I am trying to multiply two vectors together where each element of one vector

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.