R 过滤器函数在运行时返回一个充满 NA 值的数据集

问题描述

我已经从 https://www.kaggle.com/aungpyaeap/supermarket-sales

下载了一个数据集

我正在尝试过滤分支 A 上的数据,以便为分支 A 制作折线图。当我运行下面的代码时,输​​出是很多 NA 值。我已经检查了数据集中的 NA 和 Null 值。任何有关如何正确过滤分支 A 的帮助将不胜感激。

数据集的头部 -

`Invoice ID` Branch City      `Customer type` Gender `Product line`         `Unit price` Quantity `Tax 5%` Total Date       Time   Payment      cogs `gross margin percentage` `gross income` rating
  <chr>        <chr>  <chr>     <chr>           <chr>  <chr>                         <dbl>    <dbl>    <dbl> <dbl> <date>     <time> <chr>       <dbl>                     <dbl>          <dbl>  <dbl>
1 750-67-8428  A      Yangon    Member          Female Health and beauty              74.7        7    26.1  549.  2019-01-05 13:08  Ewallet     523.                       4.76          26.1     9.1
2 226-31-3081  C      Naypyitaw normal          Female Electronic accessories         15.3        5     3.82  80.2 2019-03-08 10:29  Cash         76.4                      4.76           3.82    9.6
3 631-41-3108  A      Yangon    normal          Male   Home and lifestyle             46.3        7    16.2  341.  2019-03-03 13:23  Credit card 324.                       4.76          16.2     7.4
4 123-19-1176  A      Yangon    Member          Male   Health and beauty              58.2        8    23.3  489.  2019-01-27 20:33  Ewallet     466.                       4.76          23.3     8.4
5 373-73-7910  A      Yangon    normal          Male   Sports and travel              86.3        7    30.2  634.  2019-02-08 10:37  Ewallet     604.                       4.76          30.2     5.3
6 699-14-3026  C      Naypyitaw normal          Male   Electronic accessories         85.4        7    29.9  628.  2019-03-25 18:30  Ewallet     598.                       4.76          29.9     4.1
> 

代码-

library(readr)
dataset <- read_csv("dataset.csv",col_types = cols(Date = col_date(format = "%m/%d/%Y"),Time = col_time(format = "%H:%M")))
View(dataset)
df<- dataset

sum(is.na(df))
sum(is.null(df))

df_filter_A <- filter(df,Branch == "A")
head(df_filter_A)

解决方法

我卸载了 R,现在代码可以正常工作了。我相信这与图书馆有关。我按照这个帖子卸载-

How to uninstall R and RStudio with all packages,settings and everything else?

感谢您的帮助并查看我的代码。