0

I have a set of data with 3 columns: index column (with no name), colour, colour of seed, and germination time.

How do I create a numerical variable called 'order' with values 1 to 22 (the number of data sets)?

mnel
  • 113,303
  • 27
  • 265
  • 254
math11
  • 537
  • 2
  • 6
  • 8

1 Answers1

1

I don't know if I get you right, but simplest way would be:

> order <- c(1:22)
> order
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22

No, if you run:

class(order)

you will get:

[1] "integer"

but you can easily get every element of object order (especially in a loop)

for(i in 1:length(order)){
print(order[i])
}
java_xof
  • 439
  • 4
  • 16
  • Does that turn 'order' into a variable though? – math11 Nov 28 '12 at 21:16
  • I've just tried using 'order' as part of a new ANOVA table and it won't work. So I'm guessing 'order' isn't a variable using those commands above – math11 Nov 28 '12 at 21:20
  • Watch out for using your variables name same as some functions, they can mismatch or misinterpret your code, see ?order -> it is a function! – java_xof Nov 28 '12 at 21:23