2
votes

I'm currently trying to relevel the following data frame for presentation purposes:

Report      Visual  Audio      Prob
Two Flashes one     MF-C 300   0.43775758
Two Flashes one     MF-C 3500  0.46551515
Two Flashes one     SW-C 300   0.18870707
Two Flashes one     Sw-C 3500  0.31036364
Two Flashes one     SW-MF 300  0.18165657
Two Flashes one     SW-MF 3500 0.23765657
Two Flashes one     SW-ST 300  0.17452525
Two Flashes one     SW-ST 3500 0.32036364
Two Flashes one     SW 300     0.06117172

Here is the code I'm using to relevel:

Prob.Illusion.Total.Mean$Audio = Relevel(Prob.Illusion.Total.Mean$Audio, ref = c("SW 300", "SW-ST 300", "SW-ST 3500", "SW-MF 300", "SW-MF 3500", "MF-C 300", "MF-C 3500", "MF-C 300", "MF-C 3500"))

However, R does relevel successfully but doesn't seem to like this code and gives me these warnings:

Warning messages: 1: In levels<-(*tmp*, value = if (nl == nL) as.character(labels) else paste0(labels, : duplicated levels will not be allowed in factors anymore 2: In levels<-(*tmp*, value = if (nl == nL) as.character(labels) else paste0(labels, : duplicated levels will not be allowed in factors anymore

Any ideas what is going on?

Thanks.

1
do you mean ?relevel? if so youre not using it correctly. if you replace Relevel with factor and ref with levels, then it would probably workrawr
relevelonly change the reference level: From the man page: the levels of a factor are re-ordered so that the level specified by ref is first and the others are moved downxraynaud

1 Answers

3
votes

Instead of using relevel, which only lets you set the reference level, you need to set the levels explicitly using:

Prob.Illusion.Total.Mean$Audio <- factor(Prob.Illusion.Total.Mean$Audio, levels = c("SW 300", "SW-ST 300", "SW-ST 3500", "SW-MF 300", "SW-MF 3500", "MF-C 300", "MF-C 3500", "MF-C 300", "MF-C 3500"))

Reference