Question: how to select certain columns in R
0
gravatar for mms140130
2.0 years ago by
mms14013060
mms14013060 wrote:

I have the following part of the data

      TCGA-3C-AAAU-01A-11D-A41E-01 TCGA-3C-AAAU-10A-01D-A41E-01
A1BG                           0.1302                       0.0064
A2M                            0.2586                       0.0033
A2MP1                          0.2586                       0.0033
NAT1                           0.2662                       0.0034
NAT2                           0.2662                       0.0034
SERPINA3                      -0.2761                       0.0034
         TCGA-3C-AALI-01A-11D-A41E-01
A1BG                           0.1036
A2M                            0.0309
A2MP1                          0.0309
NAT1                           0.3269
NAT2                           0.3269
SERPINA3                       0.0252

I want to select the columns that contain -01A- only , 4th place from the left

TCGA-3C-AALI-01A-11D-A41E-01

How can I do that ?

R • 905 views
ADD COMMENTlink modified 2.0 years ago by Devon Ryan91k • written 2.0 years ago by mms14013060
2

try to use "colnames, substr and which" functions in R

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by landscape95160

Hello mms140130!

It appears that your post has been cross-posted to another site: https://support.bioconductor.org/p/97884/

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLYlink written 2.0 years ago by WouterDeCoster40k

Please follow up on your previous questions. It's important to provide feedback.

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted. Upvote|Bookmark|Accept

ADD REPLYlink written 2.0 years ago by WouterDeCoster40k

I will look at my previous Questions and provide feedback ! Thank you..

ADD REPLYlink written 2.0 years ago by mms14013060
5
gravatar for Devon Ryan
2.0 years ago by
Devon Ryan91k
Freiburg, Germany
Devon Ryan91k wrote:

This is a nice example of when the dplyr package is useful. Given a dataframe, d:

> library(dplyr)
> d %>% select(contains("-01A-")) # or just 'select(d, contains("-01A"))'

The will select all columns containing "-01A-" in the column name.

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by Devon Ryan91k

Thank you very much , that was really helpful :)

ADD REPLYlink written 2.0 years ago by mms14013060
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1497 users visited in the last hour