Duplicated() removing column name

I am using duplicated(), and it is removing the column name. I have a table that has one column:
COURSE_NUMBER
[1] 201
[2]201
[3]302
[4]302...

R<-
courseNumTable <- courseNumTable[!duplicated(courseNumTable), ]

This is yielding

[1] 201
[2] 302....

while it is removing the dups the the table, it is also removing the column name when that isn't a dup. Why is this happening and how do I stop it from happening?

Try to set the drop argument.

df <- data.frame(col1 = sample(1:10, 50, replace = TRUE))
df[!duplicated(df$col1),,drop = FALSE]
#>    col1
#> 1     4
#> 2     6
#> 3     3
#> 4     8
#> 5     9
#> 9     5
#> 10   10
#> 11    2
#> 16    1

If drop is TRUE the result is coerced to the lowest possible dimension, and TRUE is the default value.
And you also can use tidyversesfilter` function.

library(tidyverse)
df <- data.frame(col1 = sample(1:10, 50, replace = TRUE))
df %>% filter(!duplicated(.$col1))
#>    col1
#> 1     3
#> 2    10
#> 3     4
#> 4     6
#> 5     2
#> 6     1
#> 7     9
#> 8     5
#> 9     8
#> 10    7

That worked. Thanks!