This is my data:
Year variable value 1951 MF12 1.441 1952 MF12 2.068 1953 RF12 2.008 1954 RF12 2.044 1955 MW12 2.288 1956 RW12 1.800
Where MF= Managed Frame, RF= Reserve Frame, MW= Managed Wind, RW= Reserve Wind. So in total 4 different levels = Managed, Reserve, Frame, Wind.
I want to create two types of factors based on these levels and add them as columns to the data frame. Factor 1 will be management.type (Managed, Reserve) and Factor 2 will be object.type (Frame, Wind).
Something like this:
Year variable value Management Object 1951 MF12 1.37845 Managed Frame 1952 MF12 1.38950 Managed Frame 1953 MW12 1.55510 Managed Wind 1954 RF12 1.66125 Reserve Frame 1955 RW12 1.62600 Reserve Wind 1956 RW13 1.58760 Reserve Wind
How can I do this using R (rather than going back and sorting in excel)? I think in terms of Management type maybe use the
start.with command to sort by starting with ‘M’ or ‘R’, but not sure how to do that. In terms of Object, is there a way to sort by words that contain letter ‘F’ or ‘W’?
Been stuck at this for hours so would appreciate any help! 🙂