简体   繁体   English

将1行实例转换为R中合适的格式以进行重复测量方差分析

[英]Converting 1 row instance to a suitable format in R for repeated measures ANOVA

I'm really struggling with how to format my data to a suitable one in R. 我真的在努力将数据格式化为R中合适的数据。

At the moment, I have my data in the format of: 目前,我的数据格式为:

ParticipantNo | Sex | Age | IV1(0)_IV2(0)_DV1 | IV1(1)_IV2(0)_DV1 | etc

There are two levels for IV1 , and 3 for IV2 , so 6 columns per DV. IV1有两个级别, IV2 3个级别,因此每个DV有6列。

I've stacked them, so that I compare all IV1 results with each other, and the same for IV2 using a Friedman test. 我将它们堆叠在一起,以便将所有IV1结果彼此进行比较,使用弗里德曼测试对IV2进行比较。

However, I'd like to compare across groups like Sex and Age, and was told ANOVA is the best for this. 但是,我想在“性别”和“年龄”等群体之间进行比较,并被告知ANOVA才是最好的选择。 I've used ANOVA directly before in SPSS, which accepts this data format. 我之前在SPSS中直接使用过ANOVA,它接受这种数据格式。

The problem I have is getting this data into the correct format in R. 我的问题是将这些数据转换为R中的正确格式。

As I understand it, it should look like: 据我了解,它应该看起来像:

1 | M | 40 | IV1(0)_IV2(0)_DV1_Result

1 | M | 40 | IV1(1)_IV2(0)_DV1_Result

1 | M | 40 | IV1(0)_IV2(1)_DV1_Result

1 | M | 40 | IV1(1)_IV2(1)_DV1_Result

1 | M | 40 | IV1(0)_IV2(2)_DV1_Result

1 | M | 40 | IV1(1)_IV2(2)_DV1_Result

Then I can do aov(sex~DV1_result, data=data) 然后我可以做aov(sex~DV1_result, data=data)

Does this seem like the correct thing to do, and if so, how can I convert from the format I have to the one I need in R? 这似乎是正确的做法吗?如果是这样,如何将我需要的格式转换为R中需要的格式?

Figured it out! 弄清楚了!

I used stack on my data, and then separate (ie s = separate(stack(data), "ind", c("IV1", "IV2") . 我在数据上使用了stack ,然后separate (即s = separate(stack(data), "ind", c("IV1", "IV2")

Then I could do the ANOVA by aov(values ~ IV1 * IV2, data = s) 然后我可以通过aov(values ~ IV1 * IV2, data = s)进行ANOVA

Hope this helps someone! 希望这对某人有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM