I have literally tried to get the average cost of the items from the Price column of my data all day long, and I just cannot figure it out. I am new to this. So please, excuse me if I did not load all information correctly. Here are the details:
- Imported a CSV file.
- Created a dataset to reveal only the columns that I needed data for.
- Attempted to find the average price of fitness items.
#clean names
clean_names(wearables)
> #clean names
> clean_names(wearables)
# A tibble: 215 × 15
   name        price body_location category company_name company_url company_mapping… company_city
   <chr>       <chr> <chr>         <chr>    <chr>        <chr>       <chr>            <chr>       
 1 "Barska GB… $49.… Wrist         Fitness  Barska       http://www… Pomona, Califor… Pomona      
 2 "Belkin GS… $24.… Arms          Fitness  Belkin       http://www… Playa Vista, Ca… Playa Vista 
 3 "Ekho Fit-… $105… Wrist         Fitness  Ekho         http://www… Dallas, Texas, … Dallas      
 4 "Fitbit Fl… $94.… Wrist         Fitness  Fitbit       http://www… San Francisco, … San Francis…
 5 "Garmin Fo… $249… Wrist         Fitness  Garmin       http://www… Olathe, Kansas,… Olathe      
 6 "Garmin In… $169… Wrist         Fitness  Garmin       http://www… Olathe, Kansas,… Olathe      
 7 "Garmin Vi… $79.… Wrist         Fitness  Garmin       http://www… Olathe, Kansas,… Olathe      
 8 "Garmin Vi… $129… Wrist         Fitness  Garmin       http://www… Olathe, Kansas,… Olathe      
 9 "Jawbone -… $112… Wrist         Fitness  Jawbone      https://ww… San Francisco, … San Francis…
10 "Jawbone U… $52.… Wrist         Fitness  Jawbone      https://ww… San Francisco, … San Francis…
# … with 205 more rows, and 7 more variables: company_u_s_state <chr>, company_country <chr>,
#   source <chr>, link <chr>, duplicates_note_1 <lgl>, id <dbl>, image <chr>
#Filter for Fitness Category
wearables <- Wearables_DFE %>% filter(Category == "Fitness")
#Verify table
view(wearables)

#Show the applicable columns
wearables %>% select(Category, Name, Body.Location, Price)
> #Filter for Fitness Category
> wearables <- Wearables_DFE %>% filter(Category == "Fitness")
> #Verify table. Please see image attached. I do not know how to save a dataset of a table.
> view(wearables)
?
#Find the average price for a wearable fitness item, excluding the NA's.
wearables %>% group_by (Body.Location) %>% drop_na %>% summarize(average_cost = mean(Price))
> #Find the average price for a wearable fitness item, excluding the NA's.
> wearables %>% group_by (Body.Location) %>% drop_na %>% summarize(average_cost = mean(Price))
# A tibble: 0 × 2
# … with 2 variables: Body.Location <chr>, average_cost <dbl>
Warning message:
In mean.default(Price) : argument is not numeric or logical: returning NA
> 
 
     
    