SEQanswers (
-   Bioinformatics (
-   -   Rename whole data sets (

IsBeth 05-22-2014 07:27 AM

Rename whole data sets
Hello! Sorry if my question seems a bit stupid, cause I think it has to be easy, but I don't have enough knowhow...
I want to rename a character string in R which contains numbers. It's something like this:

"3435" "4364" a.s.o.

I want to change that so there are words before the numbers. There must be the same words for the whole length of the object, like this:

"mygenes_3435" "mygenes_4364"...

is there a command to do this? Would it be similar if I wanted to rename a data.frame for example? I really need help, it's very urgent! =(

Jeremy 05-27-2014 09:11 PM

call that string MyString
NewString <- paste("mygenes_", MyString, sep="")

If that is a column of a data frame called DF
DF$MyString <- paste("mygenes_", DF$MyString, sep="")

dpryan 05-28-2014 01:24 AM

Another option is sprintf:


NewString <- sprintf("mygenes_%s", MyString)
Paste is easier for concatenating two strings like this, but should you want to merge multiple things (possibly with formatting), then you'll find sprintf very helpful.

All times are GMT -8. The time now is 11:50 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.