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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:48:35+00:00 2026-06-18T21:48:35+00:00

If I say l = list() and then I do l[[27]] = 100 ,

  • 0

If I say l = list() and then I do l[[27]] = 100, it will create 26 other entries with the value NULL in them. Is there a way to avoid this?

For example if I run: l <- list(); for (i in c(4,7,1)) { l[[i]] <- i^1 }

It will creat a list with entries ranging from 1 to 7, and NULL values for all the ones I did not assign. How can I avoid these spurious entries?

  • 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-18T21:48:36+00:00Added an answer on June 18, 2026 at 9:48 pm

    Use character values for the indices:

    l <- list(); for (i in c(4,7,1)) { l[[as.character(i)]] <- i^1 }
    
    > l
    $`4`
    [1] 4
    
    $`7`
    [1] 7
    
    $`1`
    [1] 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have this: private list<myClass> myCollection; Is there a programming idiom to shorten
Say I have a website that has 100 products. Then this is filtered down
I have a large list of objects (say 100k elements). Each element will have
I'm trying to obtain the top say, 100 scores from a list of scores
I have a list of doubles, for the purpose of this lets say I
I'm creating a program that will do a user-predefined number of tasks, say, 100.
I have a search results list that has say 100 items in it. When
I have a collection of Predicates , say List<Predicate<File>> . I then have a
Now I am facing a problem like this: Say I have a list of
In the web servce I say public List<Customer> GetCustomers() { PR1Entities dc = new

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.