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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:13:19+00:00 2026-06-08T18:13:19+00:00

I have a data file that is several million lines long, and contains information

  • 0

I have a data file that is several million lines long, and contains information from many groups. Below is an abbreviated section:

MARKER      GROUP1_A1   GROUP1_A2   GROUP1_FREQ GROUP1_N    GROUP2_A1   GROUP2_A2   GROUP2_FREQ GROUP2_N
rs10    A   C   0.055   1232    A   C   0.055   3221
rs1000  A   G   0.208   1232    A   G   0.208   3221
rs10000 G   C   0.134   1232    C   G   0.8624  3221
rs10001 C   A   0.229   1232    A   C   0.775   3221

I would like to created a weighted average of the frequency (FREQ) variable (which in itself is straightforward), however in this case some of the rows are mismatched (rows 3 & 4). If the letters do not line up, then the frequency of the second group needs to be subtracted by 1 before the weighted mean of that marker is calculated.

I would like to set up a simple IF statement, but I am unsure of the syntax of such a task.

Any insight or direction is 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-06-08T18:13:20+00:00Added an answer on June 8, 2026 at 6:13 pm

    Say you’ve read your data in a data frame called mydata. Then do the following:

    mydata$GROUP2_FREQ <- mydata$GROUP2_FREQ - (mydata$GROUP1_A1 != mydata$GROUP2_A1)
    

    It works because R treats TRUE values as 1 and FALSE values as 0.

    EDIT: Try the following instead:

    mydata$GROUP2_FREQ <- abs( (as.character(mydata$GROUP1_A1) != 
                                as.character(mydata$GROUP2_A1)) -                   
                              as.numeric(mydata$GROUP2_FREQ) )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First I have a PHP file that gets data and file from a HTML
I have a flash file that is loading data from XML file. After I
I have an SVG file that contains several elements (like path, circles, rectangles, etc.).
I have a file that describes input data, which is split into several other
i need to have an ascii file that have several lines in it for
I have denormalized data (coming from a file) that needs to be imported into
I want to read from one file that has several kinds of data-types. I
I have a txt file that contains data which I need to input to
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have a data file that looks like the following example. I've added '%'

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.