I have a dataframe where I need to create a new column of values using the strings in Issue_key
column and form the strings of values from the Issue_description
column.
Issue_Description_needed
is what I am seeking. I have used the lag
and summarise
functions from dplyr
but it's not the correct approach.
input <- data.frame(
Issue_Key = c("KLM391",
"KLM391.02",
"KLM391.01",
"KLM391.04",
"KLM391.01.0999993",
"KLM391.01.0999993.898",
"KLM391.01.0999993.898.asds",
"KLM391.01.0999993.898.tyut",
"KLM391.02.0999993",
"KLM391.02.0999996",
"KLM391.04.0999991",
"KLM391.04.0999998"),
Issue_description = c("L",
"M2",
"M1",
"M4",
"O123",
"P1234",
"Q12345",
"Q67809",
"XYq12",
"46525",
"4hrh4",
"fg785"),
Issue_description_needed = c(
"L",
"L.M2",
"L.M1",
"L.M4",
"L.M1.O123",
"L.M1.O123.P1234",
"L.M1.O123.P1234.Q12345",
"L.M1.O123.P1234.Q67809",
"L.M2.XYq12",
"L.M2.46525",
"L.M4.4hrh4",
"L.M4.fg785"
)
)
Output:
Issue_Key Issue_description Issue_description_needed
1 KLM391 L L
2 KLM391.01 M1 L.M1
3 KLM391.01.0999993 O123 L.M1.O123
4 KLM391.01.0999993.898 P1234 L.M1.O123.P1234
5 KLM391.01.0999993.898.asds Q12345 L.M1.O123.P1234.Q12345
6 KLM391.01.0999993.898.tyut Q67809 L.M1.O123.P1234.Q67809
7 KLM391.02 M2 L.M2
8 KLM391.02.0999993 XYq12 L.M2.XYq12
9 KLM391.02.0999996 46525 L.M2.46525
10 KLM391.04 M4 L.M4
11 KLM391.04.0999991 4hrh4 L.M4.4hrh4
12 KLM391.04.0999998 fg785 L.M4.fg785
I have searched the forum with best of my knowledge: