I am getting an error message when I am attempting to change the name of a data element in a column. This is the structure of the data frame I am using.
'data.frame': 2070 obs. of 7 variables:
$ Period: Factor w/ 188 levels "1 v 1","10 v 10",..: 158 158 158 158 158 158 158 158 158 158 ...
$ Dist : num 7548 7421 9891 8769 10575 ...
$ HIR : num 2676 2286 3299 2455 3465 ...
$ V6 : num 66.2 18.5 81 40 275.1 ...
$ Date : Factor w/ 107 levels "1/3/17","1/4/17",..: 38 38 38 38 38 38 38 38 38 38 ...
$ Type : Factor w/ 28 levels "Captain's Run",..: 5 5 5 5 5 5 5 5 5 5 ...
$ Day : Factor w/ 8 levels "Friday","Monday",..: 1 1 1 1 1 1 1 1 1 1 ...
#> Error: <text>:1:22: unexpected symbol
#> 1: 'data.frame': 2070 obs.
#> ^
```
I wish to change the value Main Session
in db$Type
to Main Training
so I can match this data frame to another I'm using. I'm using the code below to try and do this.
class(db$Type)
db$Type <- as.character(db$Type)
db$Type["Main Session"] = "Main Training"
I am getting this error message when I attempt to run the piece of code.
db$Type["Main Session"] = "Main Training"
Error in `$<-.data.frame`(`*tmp*`, Type, value = c("Main Session", "Main Session", :
replacement has 2071 rows, data has 2070
#> Error: <text>:2:7: unexpected 'in'
#> 1: db$Type["Main Session"] = "Main Training"
#> 2: Error in
#> ^
Being relatively new to R, is there anything I am missing in my code that could resolve this issue? Any suggestions will be greatly appreciated. Thank you.