#R dplyr package. Need help with an error

69 messages · Page 1 of 1 (latest)

smoky lagoon
#

Getting error. After running this code:

data = dslabs::gapminder
data %>% show_query()

Error in UseMethod("show_query") :
no applicable method for 'show_query' applied to an object of class "data.frame"

how to fix it? Pls help if you know

ionic drum
#

Dayumm it's an r question leshgoooo

ionic drum
smoky lagoon
#

Hi wang

ionic drum
#

Hi Gx

smoky lagoon
#

Because the task is like this

#

🙂

#

need to use show query

ionic drum
#

It might be useful to show the task when asking for help 🙂

smoky lagoon
#

okay

#

the first task is:
import data "dslabs::stars". Import it so that the "data %>% show_query()" code doesn't throw an error.

#

then has other one

#

i think i need to do with dplyr package. but even if i used it. it gives error(

#

when i checked the type of data it is data frame

smoky lagoon
ionic drum
#

Sorry was doing my night routine

smoky lagoon
#

no problem

ionic drum
#

Where is show_query from? Dbplyr or dplyr?

smoky lagoon
#

i think in dplyr

ionic drum
#

Can you try utils::getAnywhere(show_query)

#

Maybe it needs to be in quotes?

#

I can't remember

smoky lagoon
#

okay

#

A single object matching ‘show_query’ was found
It was found in the following places
package:dplyr
namespace:dplyr
with value

ionic drum
#

Okay so it is from dplyr

#

Interesting, I've never used that function except for in a database

smoky lagoon
#

actually i dont understand why it gives an error. But i think it's related to dplyr

ionic drum
#

You tried converting it to a tibble?

#

Do you get the same error or a different one

smoky lagoon
#

okay

ionic drum
#

What's kinda answer is that lol

smoky lagoon
#

data = dslabs::stars %>% as_tibble()
data %>% class()
[1] "tbl_df" "tbl" "data.frame"

data %>% show_query()
no applicable method for 'show_query' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"

smoky lagoon
ionic drum
#

Oh what why'd a vector get returned

smoky lagoon
#

there is no problem in data. but then again show query gives an error

#

sorry i also did this
data %>% class()

ionic drum
#

What about making it into a tbl?

smoky lagoon
#

you mean like this?
data = tbl(dslabs::stars)

ionic drum
#

Oh okay I was right

smoky lagoon
#

no applicable method for 'tbl' applied to an object of class "data.frame"

ionic drum
#

You have to convert it to a databse

smoky lagoon
#

how i can do it

ionic drum
#

Have you been taught any ways?

#

I don't want to get you in trouble for using things you're not allowed to

smoky lagoon
#

i will look

#

there was one example with tbl_memdb()

ionic drum
#

That sounds like it could work

smoky lagoon
#

but it gives error again((

#

Error in tbl_memdb(.) : could not find function "tbl_memdb"

ionic drum
#

It's from dbplyr

#

The database version of dplyr

smoky lagoon
#

oh okay

ionic drum
smoky lagoon
#

okay. i will try to do it

ionic drum
#

Hello? It shouldn't take this long lol

smoky lagoon
#

i tried then gived another error

#

))

#

oh I fixed it. i think

#

data %>% show_query()
<SQL>
SELECT *
FROM .

#

i am new in R. I think it works now

ionic drum
#

Noice good work

ionic drum
smoky lagoon
#

Thank you. I will try to do another part of question. I hope there will be no errors)

ionic drum
#

No worries

#

Feel free to come back and ask if you have more questions

#

I will however, be sleeping soon so I won't reply until I wake up and I don't think anyone else in this server helps with r so ...

smoky lagoon
#

:))

#

Thanks a lot

ionic drum
#

No problem