I have a column of data labeled in the following string format: "1.2.a.2021"; I want to replace the corresponding row in a "wk#" column currently filled with NA to the first number in the string (in this case it would be "1"). I am using strsplit() to split up the string into various characters/or made them numeric, but I want to create a for loop that will then take that first character from each row/first column and put it into the new column respective cell. There are 13 weeks in the but hundreds of data points so a loop would work best to find and match the number.
See example below.
| sample | ng | wk# |
|---|---|---|
| 1.2.a.2021 | 0.4 | NA |