0
votes

I've tried this before and it worked, but somehow when I try again to use the dplyr library it always fails to display data using the select command. can anyone provide feedback?

  Manufaktur `Layar(inci)` `Harga(Dollar)`
   <chr>              <dbl>           <dbl>

     1 Sharp                 46             736
     2 Samsung               52            1150
     3 Samsung               46             895
     4 Sony                  40             625
     5 Sharp                 42             773
     6 Samsung               46             961
     7 Samsung               40             686
     8 Sharp                 37             574
     9 Sharp                 46            1000
    10 Sony                  40             722

and when I want to display data from the table with select(tv$'Layar(inci)'), an error like this appears : Error in UseMethod("select") :no applicable method for 'select' applied to an object of class "c('double', 'numeric')"

1

1 Answers

1
votes

select expects a data.frame/tibble (based on ?select)

.data A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

and not a vector (tv$'Layar(inci)'

library(dplyr)
tv %>%
    dplyr::select(`Layar(inci)`)

using the reproducible example

data(iris)
dplyr::select(iris$Petal.Length)
Error in UseMethod("select") : 
  no applicable method for 'select' applied to an object of class "c('double', 'numeric')"

When used with correct syntax

iris %>%
   dplyr::select(Petal.Length) %>%
   head
  Petal.Length
1          1.4
2          1.4
3          1.3
4          1.5
5          1.4
6          1.7