Modify column names of big data frame
1
0
Entering edit mode
qurrat.ulain ▴ 10
@qurratulain-9376
Last seen 8.4 years ago

I have a big data frame dim(df)= 29 20664. It contains mutation and copy number variation data for genes. The column names are actually gene names. The column names currently are gene1, gene2 .... gene20664.

How can I change the column names from 1 to 19862 as gene1_mut, gene2_mut ... gene19862_mut

and from 19863 to 20664 as gene19863_CNV, gene19864_CNV..... gene20664_CNV.

I was trying following

names(geneMC)[19863:20664]<-paste("cnv_",19863:ncol(geneMC),sep="")
names(geneMC)[19863:20664]<-sprintf("cnv_%d",19863:ncol(geneMC),sep="")
 

annotation • 665 views
ADD COMMENT
0
Entering edit mode
b.nota ▴ 370
@bnota-7379
Last seen 3.8 years ago
Netherlands

names<-colnames(df)

names.mut<-names[1:19862]

names.cnv<-names[19863:20664]

names.mut2<-paste(names.mut,"mut",sep="_")

names.cnv2<-paste(names.cnv,"cnv",sep="_")

new.names<-c(names.mut2,names.cnv2)

colnames(df)<-new.names

ADD COMMENT

Login before adding your answer.

Traffic: 660 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