Error when I try to change rownames in my list
1
0
Entering edit mode
2.4 years ago
Luca ▴ 10
PancreasLungDesign
                         Individual sex   age RNA.quality..max10.    organ   tissue
GTEX-1KXAM-0226-SM-EV7AP GTEX-1KXAM   1 60-69                 7.2 Pancreas Pancreas
GTEX-18A67-1726-SM-7KFT9 GTEX-18A67   1 50-59                 7.5 Pancreas Pancreas
GTEX-14BMU-0726-SM-73KXS GTEX-14BMU   2 20-29                 7.2 Pancreas Pancreas
GTEX-13PVR-0726-SM-5S2PX GTEX-13PVR   2 60-69                 7.3 Pancreas Pancreas
GTEX-1211K-1126-SM-5EGGB GTEX-1211K   2 60-69                 7.3 Pancreas Pancreas
GTEX-11TT1-0326-SM-5LUAY GTEX-11TT1   1 20-29                 7.7 Pancreas Pancreas
GTEX-1KXAM-0426-SM-DHXKG GTEX-1KXAM   1 60-69                 9.1     Lung     Lung
GTEX-18A67-1126-SM-7KFSB GTEX-18A67   1 50-59                 8.5     Lung     Lung
GTEX-14BMU-0526-SM-73KW4 GTEX-14BMU   2 20-29                 9.2     Lung     Lung
GTEX-1211K-0826-SM-5FQUP GTEX-1211K   2 60-69                 8.2     Lung     Lung
GTEX-11TT1-1626-SM-5EQL7 GTEX-11TT1   1 20-29                 8.9     Lung     Lung
GTEX-ZYFG-0226-SM-5GIDT   GTEX-ZYFG   2 60-69                 8.7     Lung     Lung

Hello, I was trying to change the names of sex 1 and 2 of pancreas tissue, so i wanted to change the name of row 1,2,6 from 1 to P1 and the rows on 3,4,5 from 2 to P2, but when I try:

row.names((PancreasLungDesign)[1,2])="P1"

I get the error: attempt to set 'rownames' on an object with no dimensions How can i change the names for only those 6 genes? What am I doing wrong?

r • 953 views
ADD COMMENT
2
Entering edit mode
2.4 years ago

Are you trying to change rownames, or the contents of the Sex column?

You need to stop and learn some R basics, because your syntax is completely wrong. Stop and break every step you are trying to do into smaller steps, then google how to do those smaller steps.

How do you get the the value of the first entry in the Sex column? Look up how to do that. Then look up how to change that value.

ADD COMMENT
0
Entering edit mode

I am sorry but as you can see im new with r and coding generally, the question was kinda stupid, thank you for the help.

ADD REPLY
0
Entering edit mode

I dont know how to cancel it by the way

ADD REPLY
0
Entering edit mode

Everyone was new at some point. If your line of code was perfect except for using a coma where you need a colon, I would have pointed it out; it's a simple mistake that someone used to a different kind of syntax could make, and sometimes people can overlook their own stupid typos. But I don't think you understand what the rownames function even does, and how do you think the computer knows to change a value in the Sex column here you have nowhere indicated that that's the column you are interested in? You have to 1) think about what you want your code to do, 2) if it's not working break it down into substeps and check every substep to make sure they work.

ADD REPLY

Login before adding your answer.

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