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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:35:59+00:00 2026-06-12T14:35:59+00:00

I have one vector v, created with c(), that has this data: v[a,b,d,z,e,f], it

  • 0

I have one vector v, created with c(), that has this data:

 v[a,b,d,z,e,f], it must be unordered

And I have a txt file with the form:

     label      1            2          3       ....
      b        100        2000          15
      z        123          14          12
      a         55         565          55
     .....

I have extracted the txt file, that is delimited with tabs with strplit

      ext_data<-strsplit(file,"\t") 

What I want to do is to see if the elements of vector V matches one of the elements of label, it can be there like not, and after that extract the corresponding elements of the column 1 of the txt file, then the elements of column 2 and so on

I have made the matching using for loop, but is taking too much time, because the txt file contains too much data, like this (algorithmically)

      for i=1 to length(v)
             for pos=2 to ext_data      #I put pos=2 because I start in the second row
                  if match(vector) and ext_data(pos,1)  
                       retrieve data from column C     

Any suggestion?

In rough way what I want is to know if there could be a way to use the match, but with columns, maybe transforming the column label in a row?

  • 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-12T14:36:00+00:00Added an answer on June 12, 2026 at 2:36 pm

    Just creating some test data to illustrate my solution:

    testdata <- data.frame(namecol=c("b","r","a","j","z","l","s","n","t"),
                           v1=sample(1:1000,9),
                           v2=sample(1:1000,9),
                           v3=sample(1:1000,9))
    vecfind <- c("a","b","d","z","e","f")
    

    Using [[]] or $, you can select the first element of a data frame as a vector, and then using the which and %in% functions, you can get the numeric row indices and then extract the elements, like this:

    v1_elements <- testdata[which(testdata[[1]] %in% vecfind),2]
    v2_elements <- testdata[which(testdata[[1]] %in% vecfind),3]
    v3_elements <- testdata[which(testdata[[1]] %in% vecfind),4]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Application object that has a vector of GameChar objects as one
This is weird. I created a vector just fine in one class but can't
First I want to say that, I have a vector which has thousand of
I have a Django project, that has a Address model. This is used in
What I have: Vectors of different custom structs(one custom struct per vector) I used
I have lots of vectors like this one below, very sparse, lots of 'NaN'.
have one time consuming step that flattens a bunch of files. basically i'd like
Let's say we have a class that looks like this: class A { public:
I have created an abstract base class Animal which has public virtual abstract method
I have created a an OBJ loader that can import .OBJ files that were

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.