Why are my column names not working? Please help me

Hi,

I am trying to create a data.frame called "correction_factors_BRD4_norm" by dividing columns from a data.frame called "BRD4". The output is correct and has done the right division but my column names "TMT_1", "TMT_2" etc are not labeled. What is wrong with my code?

correction_factors_BRD4_norm <- data.frame(TMT_1 = BRD4[,10] / BRD4[,10],
TMT_2 = BRD4[,10] / BRD4[,11],
TMT_3 = BRD4[,10] / BRD4[,12],
TMT_4 = BRD4[,10] / BRD4[,13],
TMT_5 = BRD4[,10] / BRD4[,14],
TMT_6 = BRD4[,10] / BRD4[,15],
TMT_7 = BRD4[,10] / BRD4[,16],
TMT_8 = BRD4[,10] / BRD4[,17],
TMT_9 = BRD4[,10] / BRD4[,18],
TMT_10 = BRD4[,10] / BRD4[,19],
TMT_11 = BRD4[,10] / BRD4[,20],
TMT_12 = BRD4[,10] / BRD4[,21],
TMT_13 = BRD4[,10] / BRD4[,22],
TMT_14 = BRD4[,10] / BRD4[,23],
TMT_15 = BRD4[,10] / BRD4[,24],
TMT_16 = BRD4[,10] / BRD4[,25])

Thanks in advance.

Without this object, it's hard to tell. See the FAQ: How to do a minimal reproducible example reprex for beginners. The form of the code is ok.

dat <- data.frame(TMT_1 = mtcars[,1] / mtcars[,1],
              TMT_2 = mtcars[,1] / mtcars[,2],
              TMT_3 = mtcars[,1] / mtcars[,3],
              TMT_4 = mtcars[,1] / mtcars[,4],
              TMT_5 = mtcars[,1] / mtcars[,5],
              TMT_6 = mtcars[,1] / mtcars[,6],
              TMT_7 = mtcars[,1] / mtcars[,7],
              TMT_8 = mtcars[,1] / mtcars[,8],
              TMT_9 = mtcars[,1] / mtcars[,9])
head(dat,2)
#>   TMT_1 TMT_2   TMT_3     TMT_4    TMT_5    TMT_6    TMT_7 TMT_8 TMT_9
#> 1     1   3.5 0.13125 0.1909091 5.384615 8.015267 1.275820   Inf    21
#> 2     1   3.5 0.13125 0.1909091 5.384615 7.304348 1.233843   Inf    21

Created on 2022-12-15 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.