Rstudio isn’t showing unique values. How do I fix it

For starters, I’m using R for the Google Data Analyst certification Capstone project. I’m using the Cyclistic dataset. I’m new to R.

I’m using the Unique() function to find the unique variables in the columns, but I get the error message saying the object is not found. How do I fix this?


[1] "ride_id" "rideable_type" "started_at"
[4] "ended_at" "start_station_name" "start_station_id"
[7] "end_station_name" "end_station_id" "start_lat"
[10] "start_lng" "end_lat" "end_lng"
[13] "member_casual"

Error in unique(rideable_type) : object 'rideable_type' not found
[1] "rideable_type"

[1] "rideable_type"
[1] "spec_tbl_df" "tbl_df" "tbl" "data.frame"
Error in unique(start_station_name) :
object 'start_station_name' not found

Hi, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

I just updated it. Does it help you understand?

Well, that is not a reproducible example since you are not including sample data (I strongly recommend you to read the reprex guide) but it is enough to see where your problem is.

You are not referencing the variable correctly, columns do not exist as stand-alone objects, they are sub-elements of a data frame, so you have to reference them in the context of a data frame, see this example using a built-in data set.

#> [1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"
#> [1] setosa     versicolor virginica 
#> Levels: setosa versicolor virginica

Created on 2022-09-06 with reprex v2.0.2
So, in your case, you should type, unique(divvy_tripp_data_July_2022$rideable_type)

This topic was automatically closed 21 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.