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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:53:05+00:00 2026-06-11T16:53:05+00:00

I have multiple .csv files with a large matrix, ~300 rows and 2000 cols.

  • 0

I have multiple .csv files with a large matrix, ~300 rows and 2000 cols. I want to develop a new matrix table for each row by selecting the entire columns that have an equal value that is 1 . I would like to keep the row and column names and would like to create file with row names in a directory.

This the example of the datasets:

       pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
WHIRR-25        1              0          1            0                 1              1                1
WHIRR-28        1              0          1            0                 0              1                0
WHIRR-55        0              0          1            0                 0              0                0
WHIRR-61        0              0          0            0                 0              1                0
WHIRR-76        0              0          1            0                 0              0                0
WHIRR-87        1              1          1            0                 0              1                1
WHIRR-92        1              0          0            1                 0              1                1

So this data sets will develop an output like as below:

    Whirr-25
                   pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
 WHIRR-25        1              0          1            0                 1              1                1
 WHIRR-28        1              0          1            0                 0              1                0
 WHIRR-55        0              0          1            0                 0              0                0
 WHIRR-61        0              0          0            0                 0              1                0
 WHIRR-76        0              0          1            0                 0              0                0
 WHIRR-87        1              1          1            0                 0              1                1
 WHIRR-92        1              0          0            1                 0              1                1

Whirr-28
                pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
 WHIRR-28        1              0          1            0                 0              1                0
 WHIRR-55        0              0          1            0                 0              0                0
 WHIRR-61        0              0          0            0                 0              1                0
 WHIRR-76        0              0          1            0                 0              0                0
 WHIRR-87        1              1          1            0                 0              1                1
 WHIRR-92        1              0          0            1                 0              1                1

Whirr-55

             pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java

WHIRR-55        0              0          1            0                 0              0                0
WHIRR-76        0              0          1            0                 0              0                0
WHIRR-87        1              1          1            0                 0              1                1

Whirr-61
          pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
WHIRR-61        0              0          0            0                 0              1                0
WHIRR-87        1              1          1            0                 0              1                1
WHIRR-92        1              0          0            1                 0              1                1

Whirr-76
               pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
WHIRR-76        0              0          1            0                 0              0                0
WHIRR-87        1              1          1            0                 0              1                1

Whirr-87
              pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
WHIRR-87        1              1          1            0                 0              1                1
WHIRR-92        1              0          0            1                 0              1                1

Whirr-92
              pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
 WHIRR-92        1              0          0            1                 0              1                1

I applied this script, but the script only create new table based on columns, not rows:

 dat <- read.table(file="Task_vs_Files_Proj.csv", header=T, sep=",", row.names=1) 
    dat

    apply( sapply(dat , function(x) return( as.logical(x) ) ), 2, function(x) dat[x, ])

$pom.xml.
        pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
    WHIRR-25        1              0          1            0                 1              1                1
    WHIRR-28        1              0          1            0                 0              1                0
    WHIRR-87        1              1          1            0                 0              1                1
    WHIRR-92        1              0          0            1                 0              1                1

    $ZooKeeper.java
             pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
    WHIRR-87        1              1          1            0                 0              1                1

    $HBase.java
             pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
    WHIRR-25        1              0          1            0                 1              1                1
    WHIRR-28        1              0          1            0                 0              1                0
    WHIRR-55        0              0          1            0                 0              0                0
    WHIRR-76        0              0          1            0                 0              0                0
    WHIRR-87        1              1          1            0                 0              1                1

Appreciate help from the expert here…Thank you

  • 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-11T16:53:07+00:00Added an answer on June 11, 2026 at 4:53 pm

    As far as I can see, you want

    # cycle through all rows
    for(which_row in seq_len(nrow(.data))){
      # get the subset of the rows from this row 
      subset_data <- .data[which_row:nrow(.data),]
      # which elements for each column == 1
      which_one <- lapply(subset_data, function(x){which(as.logical(x))})
      # drop the columns where there are no 1's
      which_one <- Filter(function(x){length(x) >0},which_one)
      # filter to those which == 1, and then get the unique combination
      # of rows (sorted to original order)
      which_rows <- sort(Reduce(union,Filter(function(x) {1 %in% x}, which_one)))
      # the file name
      file_name <- sprintf('file_%s.csv', row.names(.data)[which_row])
      # save
      write.csv(subset_data[which_rows,], file_name, row.names = T)
      # prints the data set to the console for checking
      print(subset_data[which_rows,])
      # message to show what file is created
      message(sprintf('Saving %s', file_name))
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple csv files with the same scheme, and I want to import
I have CSV files that have multiple columns that are sorted. For instance, I
I have a requirement to download multiple CSV files from a remote FTP site.
I have multiple .csv files and I combined them in single .csv file with
I have multiple CSV files which I need to parse in a loop to
I have multiple csv files with date as filename (20080101.csv to 20111031.csv) in a
I'm parsing a large csv files - about 500 meg (many rows, many columns).
Using Magento CE 1.7, I have uploaded multiple csv files to create categories, create
I have multiple 1.5 GB CSV Files which contain billing information on multiple accounts
Hi I have a ton of data in multiple csv files and filter out

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.