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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:57:25+00:00 2026-06-12T04:57:25+00:00

I have data in a matrix in the following way: label 1 2 3

  • 0

I have data in a matrix in the following way:

label     1        2      3       4
id_101   10       30      43      32
id_102    3       32     43       43
id_111    45      34     22       66
id_201    87      65     66       34
id_202    45      76     76       44
......

this data has been transformed in a list so it is like:

[[1]]
     [1]  label   1     2       
     [3]      3   4
[[2]]
     [1]  id_101 .....

 ......

what I want is to know if a value a matches one of the values from the column named label. For that purpose I am using a for loop with the match instruction:

    a<-"id_201"    ///for example
for (pos in 2:length(matrix))
{

    if (!is.na(match(a,tabd[[pos]][[1]])))
    {
        found<-1
        print(found)
        break
    }
}
    if (found) print(pos)

I was wondering if there is an efficient way to look if the value from the variable a matches any value of the column under label and to get its position, but without using the for loop.
Thanks

  • 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-12T04:57:26+00:00Added an answer on June 12, 2026 at 4:57 am

    I have made a list somewhat like what you describe, although it prints with surounding double quotes. Working with it suggests this should work

    which( sapply(txtList, "[", 1) == a )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following data matrix in Matlab, I am trying to actually split this
I have a matrix of objects that contains data in this form: name A,2,name
I have data from travel diaries which has been read in from a csv
I currently have data that is in the following format (note, this is 1
I have the following code using data.frames, and I'm wondering how to write this
I have a data set which consists of an ID and a matrix (n
I have a matrix of data (the columns represent time, and the rows spectrum
I have a matrix of data, m : 12345 12348 2011-05-13 NA 0.18001079 2011-05-16
Suppose I have a matrix of weights, and another matrix of data values. Can
I have a matrix A which I want to convert into a data.frame of

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.