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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:36:08+00:00 2026-05-30T00:36:08+00:00

I am trying to remove a component from list in R, but it is

  • 0

I am trying to remove a component from list in R, but it is not working.

I have list like this:

> myList
[[1]]
[[1]][[1]]
[1] "Sunny"  "Cloudy" "Rainy" 

[[1]][[2]]
[1] "Warm" "Cold"

[[1]][[3]]
[1] "Normal" "High"  

[[1]][[4]]
[1] "Strong" "Weak"  

[[1]][[5]]
[1] "Warm" "Cool"

[[1]][[6]]
[1] "Same"   "Change"


[[2]]
[[2]][[1]]
[1] "Sunny"  "Cloudy" "Rainy" 

[[2]][[2]]
[1] "Warm" "Cold"

[[2]][[3]]
[1] "Normal" "High"  

[[2]][[4]]
[1] "Strong" "Weak"  

[[2]][[5]]
[1] "Warm" "Cool"

[[2]][[6]]
[1] "Same"   "Change"

Can I remove a component like this: > myList = mylist[[-particularIndex]]? I want a result like this:

[[1]]
[[1]][[1]]
[1] "Sunny"  "Cloudy" "Rainy" 

[[1]][[2]]
[1] "Warm" "Cold"

[[1]][[3]]
[1] "Normal" "High"  

[[1]][[4]]
[1] "Strong" "Weak"  

[[1]][[5]]
[1] "Warm" "Cool"

[[1]][[6]]
[1] "Same"   "Change"

I can’t make a string name label for that list. I have to reference rows by index(particular index) (using rownames(myList) to delete something won’t help me).

  • 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-30T00:36:09+00:00Added an answer on May 30, 2026 at 12:36 am

    I think you came very close to the right answer:

    > x <- list(list(1:3, 4:6), list(4:7, 2:3), list(4:6,1:2))
    > x[-2]
    [[1]]
    [[1]][[1]]
    [1] 1 2 3
    
    [[1]][[2]]
    [1] 4 5 6
    
    
    [[2]]
    [[2]][[1]]
    [1] 4 5 6
    
    [[2]][[2]]
    [1] 1 2
    

    The above works to get rid of the original second component. Note single square brackets, and compare with:

    x[[-2]]

    Error in x[[-2]] : attempt to select more than one element
    

    Double squrare brackets do not work. (Actually that does work if there are only two compoennts in the list, but do not depend on that.)

    There are numerous places that explain single versus double square brackets. One of them is Circle 8.1.54 of ‘The R Inferno’ http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

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

Sidebar

Related Questions

I'm trying to remove all but the first child component from a Java Container.
In this small, but full example, I am trying to recreate a dual list
Im trying to have a searchbox on the top of my list view. But
I'm trying to remove a color from a picture imported (JPG) in Flash CS4
I'm trying to remove a class attribute from an element and add the class
I am trying to remove a directory with rmdir , but I received the
I am trying to remove the attribute xmlns=http://webdev2003.test.com from the following xml using xsl/xslt,
I'm trying to remove contents of particular div which are basically list items and
I am trying to add CakePHP's Security Component to my Application, but it slows
I have some xml, I want to give it to a List dataprovider, but

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.