[R] multiple t-test with different species and treatments
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Tue Dec 15 16:43:56 CET 2020
Unless there is good reason not to, always cc r-help, which I have done
here.
Bert Gunter
On Tue, Dec 15, 2020 at 1:16 AM Lingling Wen <wenlingling912 using gmail.com>
wrote:
> Dear Bert Gunter,
> Good day,
> Thank you for your comments about the posting policy. I am sorry for
> bothering you with the text against the posting policy in this list. I will
> read the policy carefully and improve it in my future posting.
> Regarding the question I asked, actually, it is for my experiment data
> analysis but not homework. I've tried code as followed:
> library(dplyr)
> library(tidyverse)
> library(rstatix)
> library(ggpubr)
> test <- read.csv(file.choose(), header=TRUE)
> print(test)
>
> mydata <- test %>%
> pivot_longer(
> cols = c(3:8),
> names_to = "Metabolites",
> values_to = "Relative content",
> values_drop_na = FALSE)
>
> mydata
> stat <- group_by(mydata, Metabolites,Treatment) %>%
> t_test('Relative content' ~ Treatment) %>%
> adjust_pvalue(method = "BH") %>%
> add_significance()
>
> When I run the code, it always shows error like this: Error in
> terms.formula(formula) : invalid term in model formula.
> Because I have a lot of metabolic data to deal with, I think R will help
> to save a lot of time so I am learning to use it. But I could not figure
> out what's the problem when it gives error feedback.
>
> It would be very appreciated if I could get help from the list.
> Thank you!
>
> Lingling
>
>
>
>
> On Mon, 14 Dec 2020 at 01:19, Bert Gunter <bgunter.4567 using gmail.com> wrote:
>
>> 1. Please read and follow the posting guide linked below.
>> 2. No html -- this is a plain text list.
>> 3. Use ?dput to provide us your data so that we don't have to convert it
>> for you.
>> 4. We expect you to first make an effort to do your own coding. See
>> ?t.test, which you could also
>> have found yourself by a web search (rseek.org is a reasonable place to
>> search from for R-related stuff,
>> though I have usually found that a plain google search does the job).
>> 5. Is this homework? -- this list has a no homework policy (see the
>> posting guide).
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Sun, Dec 13, 2020 at 2:33 PM Lingling Wen <wenlingling912 using gmail.com>
>> wrote:
>>
>>> Dear R users,
>>> I would like to ask for help with the code of multiple t-test. I have a
>>> dataset as followed:
>>> Species Treatment var1 var2 var2 var4 var5 var6
>>> Blue D 0.022620093 0.125079631 0.04522571 0.010105835 0.013418019
>>> 1.455646741
>>> Blue D 0.02117295 0.073544277 0.0311234 0.008742305 0.03261776
>>> 0.982196898
>>> Blue D 0.021896521 0.112681274 0.05664344 0.013512548 0.032380618
>>> 1.777003683
>>> Green D 0.032749726 0.087705198 0.13699174 0.009902168 0.083534492
>>> 1.553758965
>>> Green D 0.036468693 0.115829755 0.10941521 0.012139481 0.206929915
>>> 2.610557732
>>> Green D 0.043594022 0.062832712 0.12232853 0.015045559 0.111687593
>>> 1.99552401
>>> Orange D 0.022617656 0.11465489 0.02882994 0.013304181 0.018175693
>>> 1.72075866
>>> Orange D 0.026211773 0.099294867 0.03387876 0.013408254 0.02971197
>>> 2.184955376
>>> Orange D 0.032205662 0.057267709 0.03883165 0.007744362 0.026553323
>>> 1.27255601
>>> White D 0.041135469 0.085531343 0.06921425 0.011496168 0.010196895
>>> 0.573205411
>>> White D 0.045142458 0.111429194 0.03546278 0.009196729 0.009968818
>>> 0.748529991
>>> White D 0.031471913 0.050175149 0.05233851 0.011447205 0.010424973
>>> 0.92385457
>>> Blue W 0.022222296 0.112334911 0.04080824 0.016064488 0.031047157
>>> 0.885523847
>>> Blue W 0.040238733 0.121941307 0.04239768 0.010310538 0.020106944
>>> 0.751643349
>>> Blue W 0.031508947 0.131547704 0.05212774 0.015720985 0.013932284
>>> 0.881234886
>>> Green W 0.021070032 0.121018603 0.38202466 0.022152283 0.038479532
>>> 0.662605036
>>> Green W 0.026562365 0.108269047 0.44028708 0.019344875 0.090798566
>>> 0.746330971
>>> Green W 0.02926478 0.084080729 0.32376224 0.012609717 0.097744041
>>> 0.969301308
>>> Orange W 0.02456562 0.134535891 0.09135624 0.007701481 0.017310058
>>> 0.966322354
>>> Orange W 0.032095541 0.149347595 0.06048885 0.010332579 0.017457175
>>> 0.561561725
>>> Orange W 0.039120696 0.141941743 0.02962146 0.005889924 0.017162941
>>> 0.502529091
>>> White W 0.033903057 0.061460583 0.0492955 0.012457767 0.029929334
>>> 0.70986421
>>> White W 0.033630233 0.115782233 0.02675399 0.021391535 0.023774961
>>> 1.176680075
>>> White W 0.030638581 0.065074112 0.03678494 0.014781912 0.03529703
>>> 0.805500558
>>> I wanted to perform a t-test between the treatment "D" and "W" of each
>>> species for all of the variables (var1, var2,...). Could anyone suggest
>>> the packages or code for this analysis?
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
[[alternative HTML version deleted]]
More information about the R-help
mailing list