Sunday, March 15, 2015

R: Renaming Row numbers (Identifiers)

Many a times in R you have a dataset for which R provides a default numerical representation for identifying the individual rows :

> myData <- cbind(x = 3, y = c(4:1, 2:5))
> myData
     x  y
[1,]  3  4
[2,]  3  3
[3,]  3  2
[4,]  3  1
[5,]  3  2
[6,]  3  3
[7,]  3  4
[8,]  3  5
If you want to rename the rows as per your needs, you can do so by running the following command:

> dimnames(myData)[[1]] <- letters[1:8]
> myData
   x y
a  3  4
b  3  3
c  3  2
d  3  1
e  3  2
f  3  3
g  3  4
h  3  5
Happy programming!

No comments:

Troubleshooting Packet Drops in SolarFlare Onload 10G PCI Card

If you see lots of packet drops in your onload accelerated application even after going the troubleshooting discussion we did over here ,...