Im really new to R so Im sorry if I dont make total sense.
I have a DF with data collected in several different areas, called STAND. I need to create a sequence for my data running from 1:3, but is has to restart the sequence when it comes to a new STAND number.
Here is some dummy data
STAND TREE_SPECIES DIAMETER
1 101737 Pine 276
2 101737 Spruce 98
3 101737 Spruce 104
4 101737 Leaf 53
5 155897 Spruce 82
6 155897 Spruce 61
7 155897 Leaf 97
8 155897 Spruce 89
9 155897 Spruce 75
10 202568 Spruce 46
11 202568 Spruce 56
12 202568 Pine 204
13 202568 Spruce 132
14 202568 Spruce 93
I want it to look like this:
STAND TREE_SPECIES DIAMETER SEQ
1 101737 Pine 276 1
2 101737 Spruce 98 2
3 101737 Spruce 104 3
4 101737 Leaf 53 1
5 155897 Spruce 82 1
6 155897 Spruce 61 2
7 155897 Leaf 97 3
8 155897 Spruce 89 1
9 155897 Spruce 75 2
10 202568 Spruce 46 1
11 202568 Spruce 56 2
12 202568 Pine 204 3
13 202568 Spruce 132 1
14 202568 Spruce 93 2
If it is any help I have a total of 7416 Rows in my DF divided on 90 STANDS.
So far I've tried:
myDF$SEQ <- seq(1:3)
But that only lists 1:3 over the whole df.
Really greatful for your help!