Replace column name in data-frame
2
0
Entering edit mode
16 months ago

Dear Biostars community, 1. Does anyone know how we remove default column names (integer value) in the data frame to the first row in R studio? 2. How to compile clinical information with RNA-seq data from two CSV files with matching patients IDs. I will be grateful to have your suggestions. Thank you very much! Imran

RNA-Seq • 373 views
ADD COMMENT
0
Entering edit mode

Hey Imran! Can you share some examples of your data? Also, what have you already tried? When you paste your examples [of your data], can you then highlight the output and press the 101 010 button for formatting.

ADD REPLY
0
Entering edit mode

X1 X2 X3 X4 X5 X6 X6 X7 Patient_id Condition tcga_counts A1BG A1CF A2BP1 A2LD1 A2ML

Thank you. Here is my question. I wanted to paste a screenshot but I can't see any possibility. Anyways

1) I got more than 20000 columns in DF 1. Just as an example I need to replace all column names (X1 to X7) values with raw 1 values (Patient_id to A2ML).

2) I have all patient's gender in another table. The only variable common between the two tables is the patient's ID. Is there any way I can combine two data frames into one table with matching patients ID?

ADD REPLY
0
Entering edit mode

@ imrankhanbioinfo How did you get two columns with the same name? You can use rename (from tidyr) to rename columns. Use join functions esp inner_join from dplyr or sqldf package to join two dataframes with common column name. It always would help if you can post example data and expected outcome with proper forum formatting here.

ADD REPLY
2
Entering edit mode
16 months ago
Asaf 8.6k
  1. You can change colnames(X):

    Y <- colnames(X)
    Y[1] = "newName"
    colnames(X) <- Y
    
  2. You can use merge in base R or join if you are using tidyverse. (As a side note: you probably want Sex, not Gender)

ADD COMMENT

Login before adding your answer.

Traffic: 1670 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6