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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:53:46+00:00 2026-05-23T13:53:46+00:00

I am a relatively new R user, and most of the complex coding (and

  • 0

I am a relatively new R user, and most of the complex coding (and packages) looks like Greek to me. It has been a long time since I used a programming language (Java/Perl) and I have only used R for very simple manipulations in the past (basic loading data from file, subsetting, ANOVA/T-Test). However, I am working on a project where I had no control over the data layout and the data file is very lengthy.

In my data, I have 172 rows which feature the Participant to a survey and 158 columns, each which represents the question number. The answers for each are 1-5. The raw data includes the number “99” to indicate that a question was not answered. I need to exclude any questions where a Participant did not answer without excluding the entire participant.

Part  Q001  Q002  Q003  Q004
1      2      4    99    2
2      3      99   1     3
3      4      4    2     5
4      99     1    3     2
5      1      3    4     2

In the past I have used the subset feature to filter my data
data.filter <- subset(data, Q001 != 99)
Which works fine when I am working with sets where all my answers are contained in one column. Then this would just delete the whole row where the answer was not available.

However, with the answers in this set spread across 158 columns, if I subset out 99 in column 1 (Q001), I also filter out that entire Participant.

I’d like to know if there is a way to filter/subset the data such that my large data set would end up having ‘blanks’ when the “99” occured so that these 99’s would not inflate or otherwise interfere with the statistics I run of the rest of the numbers. I need to be able to calculate means per question and run ANOVAs and T-Tests on various questions.

Resp  Q001  Q002  Q003  Q004
1      2      4          2
2      3           1     3
3      4      4    2     5
4             1    3     2
5      1      3    4     2

Is this possible to do in R? I’ve tried to filter it before submitting to R, but it won’t read the data file in when I have blanks, and I’d like to be able to use the whole data set without creating a subset for each question (which I will do if I have to… it’s just time consuming if there is a better code or package to use)

Any assistance would be greatly appreciated!

  • 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-23T13:53:47+00:00Added an answer on May 23, 2026 at 1:53 pm

    You could replace the “99” by “NA” and the calculate the colMeans omitting NAs:

    df <- replicate(20, sample(c(1,2,3,99), 4))
    colMeans(df) # nono
    
    dfc <- df
    dfc[dfc == 99] <- NA
    colMeans(dfc, na.rm = TRUE) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am a first time user here, and still relatively new to SQL.
Being relatively new to the .net game, I was wondering, has anyone had any
Caveat: I'm relatively new to coding as well as TextMate , so apologies if
I'm relatively new to Nant, what i'd like to do is have a task
I am relatively new to C#, having done most of my previous programming in
I am a relatively new user of the ActiveRecord pattern. I was wondering if
I am relatively new to Rails. I have a User model through Devise. I
Relatively new to rails and trying to model a very simple family tree with
Being relatively new to functional programming, I expend lots of energy wondering is this
I'm relatively new to J2ME and about to begin my first serious project. My

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.