Error: Can't subset columns that don't exist.
0
0
Entering edit mode
3.0 years ago

Hi All, I have the following dataframe:

> head(allTF_NFIC_TPM_df)
  Gene     Sample      TPM    TF Genotype
1 Nfic SRR4103512 2.097590 Ptf1a       WT
2 Nfic SRR4103513 1.989032 Ptf1a       WT
3 Nfic SRR4103514 0.475040 Ptf1a       WT
4 Nfic SRR4103515 0.498004 Ptf1a       WT
5 Nfic SRR4103516 0.588734 Ptf1a       WT
6 Nfic SRR4103517 0.820988 Ptf1a       KO

The TF column has three subgroups: Ptf1a, Mist1, and Nr5a2. Within each subgroup, I want to compare TPM values between WT and KO. Thus, I executed the following:

cmeans <- compare_means(TPM ~ Genotype, data = allTF_NFIC_TPM_df, method = "t.test", paired = F, group.by = TF)

However, I get an error that says:

Error: Can't subset columns that don't exist. x Column `Ptf1a` doesn't exist.

I partly understand that something's wrong with the group.by argument. I have looked around but was unable to find a solution. I hope someone from the community can help me find one. Thanks.

R ggpubr • 4.7k views
ADD COMMENT
1
Entering edit mode

Check if you are using correct data frame. Check if group.by column is factor and correct group.by = TF to group.by = "TF". To my understanding your function should fail with a different error unless object TF exists.

ADD REPLY
0
Entering edit mode

Thanks for the suggestion(s). Changing group.by = TF to group.by = "TF" worked. However, I do not understand the logic behind this.

ADD REPLY
0
Entering edit mode

group.by = TF (group.by existing object TF)

group.by = "TF" (group.by column TF in the data, in this context)

ADD REPLY

Login before adding your answer.

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