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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:23:35+00:00 2026-05-24T22:23:35+00:00

I have a large data set with 11 columns and 100000 rows (for example)

  • 0

I have a large data set with 11 columns and 100000 rows (for example) in which i have values 1,2,3,4. Where 4 is a missing value. What i need is to compute the Mode. I am using following data and function

ac<-matrix(c("4","4","4","4","4","4","4","3","3","4","4"), nrow=1, ncol=11)  

m<-as.matrix(apply(ac, 1, Mode))

if i use the above command then it will give me “4” as the Mode, which i do not need. I want that the Mode will omit 4 and display “3” as Mode, because 4 is a missing value.

Thanks in advance.

  • 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-24T22:23:36+00:00Added an answer on May 24, 2026 at 10:23 pm

    R has a powerful mechanism to work with missing values. You can represent a missing value with NA and many of the R functions have support for dealing with NA values.

    Create a small matrix with random numbers:

    set.seed(123)
    m <- matrix(sample(1:4, 12, replace=TRUE), ncol=3)
    m
         [,1] [,2] [,3]
    [1,]    2    4    3
    [2,]    4    1    2
    [3,]    2    3    4
    [4,]    4    4    2
    

    Since you represent missingness by the value 4, you can replace each occurrence by NA:

    m[m==4] <- NA
    m
    
         [,1] [,2] [,3]
    [1,]    2   NA    3
    [2,]   NA    1    2
    [3,]    2    3   NA
    [4,]   NA   NA    2
    

    To calculate, for example, the mean:

    mean(m[1, ], na.rm=TRUE)
    [1] 2.5
    
    apply(m, 1, mean, na.rm=TRUE)
    [1] 2.5 1.5 2.5 2.0
    

    To calculate the mode, you can use the function Mode in package prettyR: (Note that in this very small set of data, only the 4th row has a unique modal value:

    apply(m, 1, Mode, na.rm=TRUE)
    [1] ">1 mode" ">1 mode" ">1 mode" "2"     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large data set and I would like to read specific columns
I have a very large (millions of rows) SQL table which represents name-value pairs
Interpolating Large Datasets I have a large data set of about 0.5million records representing
I have a very large possible data set that I am trying to visualize
I have a large set of data (a data cube of 250,000 X 1,000
I have a costumer showing Notepad with a large set of data that looks
I have situation where a user can manipulate a large set of data (presented
I've got a large set of data in Excel 2007, but the rows should
I have a reasonably large data set and would like to store it in
I have a large result set assembled in a parent/child relationship. I need to

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.