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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:51:43+00:00 2026-06-12T19:51:43+00:00

I have a data.frame with 16 columns. Here’s one example row. > data[16,] V1

  • 0

I have a data.frame with 16 columns. Here’s one example row.

    > data[16,]
                      V1              V2              V3                 V4
    16 comp27182_c0_seq4 ENSP00000442096 ENSG00000011143 ENSFCAP00000011376
                       V5                V6                V7                V8
    16 ENSFCAG00000012261 comp48601_c0_seq1 comp19130_c0_seq3 comp22796_c2_seq3
                       V9 V10                V11                V12
    16 comp146901_c0_seq1     comp157916_c0_seq1 comp158124_c0_seq1
                      V13               V14 V15 V16
    16 comp229797_c0_seq1 comp61875_c0_seq2

I’m only interested in columns 1 and 6-16. The first column contains the name I would like to use as a column name in the matrix, 6 to 16 may contain either a string or ” (nothing).
I would like to transform this data.frame into a matrix showing 1 or 0, reflecting the content in columns 6-16.

                  V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11
comp27182_c0_seq4 1  1  1  1  0  1  1  1  1   0   0

I’ve trying to use mask without success. I’m sure there’s a very easy option out there.

Thanks for any help.

  • 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-12T19:51:44+00:00Added an answer on June 12, 2026 at 7:51 pm

    Try this:

    do.call(cbind, lapply(c(1,6:16), 
            function(x) as.numeric(nchar(as.character(data[,x])) > 0)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame with 2 columns: Node A, Node B. Each entry in
I have a data frame with two columns. First column contains categories such as
I have a data frame where some of the columns contain NA values. How
I have a data frame with 50000 rows and 200 columns. There are duplicate
I have a data frame of daily data: df with four columns: Date, A,
I have a data frame with an id column and some (potentially many) columns
I have a data frame that is some 35,000 rows, by 7 columns. it
Let's assume that we have a data frame x which contains the columns job
I have two columns in a data frame, and I have been able to
I have a data.frame , called so_data. Columns 13:23 are list s, which hold

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.