-1

My data (group) has 300 variables showing which group it belong to in the second row..There are a total of 6 groups

2017 2766 1737 1745 1747 1883 1884 1821 1900 ......
3    4    6    3    3    3    3    3    3    ......

If I do this:

group=="6" 

It will show if the variables are true or false if they belong to group 6 as below

2017  2766  1737 1745  1747  1883  1884  1821  1900  ..............
FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE ..............

I am trying to get it list out all the variables which belong to individual group.
For example I want to ask what variables belong to group 6

I tried this but it gave a null results:

names(group=="6")

I then want to save the names into a csv.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Maisarah
  • 21
  • 1
  • 3

1 Answers1

0

Try

colnames(group)[which(group=="6")]

when group is a data.frame or else

names(group)[which(group=="6")]
Wannes Rosiers
  • 1,680
  • 1
  • 12
  • 18