0

raw Data looks like this:

  type value
1  a    10
2  a    20
3  a    30
4  b    50
5  b    10
6  b    20

melted data looks like this:

1 a value 10
2 b value 10

I want to apply wilcox.test to a,b To check whether a is greater than b. How to do that? thanks.

mnel
  • 113,303
  • 27
  • 265
  • 254
tmjdone
  • 15
  • 5

1 Answers1

1

I don't think you need to melt the data.

given a data.frame raw containing your raw (unmelted) data

wilcox.test(value ~ type, data = raw)

should work.

mnel
  • 113,303
  • 27
  • 265
  • 254
  • I did that: > wilcox.test(value ~ type, data=raw) Wilcoxon rank sum test with continuity correction data: value by type W = XXXXXX, p-value < 3.3e-20 alternative hypothesis: true location shift is not equal to 0, but how can I know it is test a>b or b>a ? – tmjdone Apr 08 '13 at 02:30
  • I believe you are a R professional, can you suggest me some books to manipulate R data structure? – tmjdone Apr 08 '13 at 02:34
  • @user1138113 -- the test (by default) is two sided. – mnel Apr 08 '13 at 02:42
  • I want to test whether a is greater than b: I used "r=wilcox.test(value ~ type, data=df,paired=F,alternative='greater',conf.int = TRUE)", Is this test "first appeared in data ('a' in above example) greater than second" ? Thank you very much for your help :-) – tmjdone Apr 08 '13 at 02:56
  • x will be the first by the ordering of the levels within `df$type`. Look at `levels(df$type)` – mnel Apr 08 '13 at 02:59