Whenever i run this code chunk or other chunks like this i get this error.
data_1_year_v2 %>%
group_by(member_casual) %>%
count(member_casual)
Error: object 'member_casual' not found
It's a bit hard to answer the question without seeing more of your code, but in principle you are not thinking correctly about what is left after you've done the group_by
.
group_by
creates a set of smaller dataframes that contain the variables that you did not include in the group_by
; your count()
function only sees those variables. You can't count()
what's not there!
Also: Consider using summarize()
instead of count()
i apologize im new to this but what i want to do is see the amount of members and casual riders there are in this dataset (data_1_year_v2) and when i used the summarize() function i just got blank rows
Welcome to the forum.
We really need to see need to see all of your code and some sample data. See
FAQ Asking Questions
Screenshot are usually not very useful. A good way is to copy your code and paste it between
```
``
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```
```
The solution is going to look like this:
data_1_year_v2 %>%
group_by(member_casual) %>%
summarise(num = n())
Or in base R you could just use
table(factor(data_1_year_v2$member_casual))
this usually mean the object is not found in the session. If this happens on during rendering, check that you are correctly loading the data in one of the previous chunk. All data needs to be made available from within the Rmd itself.
You need load the member_casual
object because in Rmarkdown run each line one by one.
A good practice when working with Rmd
is to put in the first chunk all the libraries and load the databases. So you can be sure that later when you call these objects they will already be loaded.
The error you get is because Rmd
does not recognize the object, maybe it is loaded but in another script and not in the Rmd
you are working with. It is usual that it happens when you start with Rmd
.
# first chunk
# load libraries
# load data set
This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.