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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:26:28+00:00 2026-05-23T23:26:28+00:00

I have a character matrix with differing numbers of NA in different rows. I

  • 0

I have a character matrix with differing numbers of NA in different rows. I would like to create a structure that has the same number of rows, with all the NAs removed.

  • 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-23T23:26:29+00:00Added an answer on May 23, 2026 at 11:26 pm

    Using a simple apply :

    x <- matrix(1:10,ncol=2)
    x[c(4,7,8)] <- NA
    
    apply(x,1,na.exclude)
    

    edit : if all rows have exactly the same amount of NA’s, then this will return a matrix. For conversion of this matrix to a list, see : How to convert a matrix to a list of column-vectors in R? .

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

Sidebar

Related Questions

If I have a character (say +) inside text and I would like to
I have a character array that contains a phone number of the form: (xxx)xxx-xxxx
We have legacy character codes that we want to store as numbers in a
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().
I have a string that contains a czech character. the string is 0bálka This
I have a character that's say, 20 by 10 pixels large and I have
I have a character pointer like this char *ptr; I can allocate values to
I have a character vector with letters and numbers: c("A", "1", "2", "3", "B",
Suppose I have a simple multidimensional structure, like this one: somestr<-array(sample.int(2, 120, replace=TRUE), dim=c(4,5,6))
I have a character array and I'm trying to figure out if it matches

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.