Sort column by date after it is in my environment using filter












0














My current setup



How do I filter the end_time column for data only after 12/01/2018 and then sum these data after this date?



Below is what I have already tried.



setwd("/Users/jackbell/Desktop")
bookings<- read.csv("bookings_data_data_analyst_test.csv", header= TRUE)
end_time<- bookings %>%select(end_time)
end_time
new_date <- filter(end_time< as.Date("12/01/2018"))









share|improve this question





























    0














    My current setup



    How do I filter the end_time column for data only after 12/01/2018 and then sum these data after this date?



    Below is what I have already tried.



    setwd("/Users/jackbell/Desktop")
    bookings<- read.csv("bookings_data_data_analyst_test.csv", header= TRUE)
    end_time<- bookings %>%select(end_time)
    end_time
    new_date <- filter(end_time< as.Date("12/01/2018"))









    share|improve this question



























      0












      0








      0







      My current setup



      How do I filter the end_time column for data only after 12/01/2018 and then sum these data after this date?



      Below is what I have already tried.



      setwd("/Users/jackbell/Desktop")
      bookings<- read.csv("bookings_data_data_analyst_test.csv", header= TRUE)
      end_time<- bookings %>%select(end_time)
      end_time
      new_date <- filter(end_time< as.Date("12/01/2018"))









      share|improve this question















      My current setup



      How do I filter the end_time column for data only after 12/01/2018 and then sum these data after this date?



      Below is what I have already tried.



      setwd("/Users/jackbell/Desktop")
      bookings<- read.csv("bookings_data_data_analyst_test.csv", header= TRUE)
      end_time<- bookings %>%select(end_time)
      end_time
      new_date <- filter(end_time< as.Date("12/01/2018"))






      r






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 22:31









      TrebuchetMS

      2,0011619




      2,0011619










      asked Nov 22 at 18:04









      Jack Bell

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          1














          We need to convert it to Date class. Based on the image and the OP's code, 'end_time' seems to be the column name and there is also an object created with the same name. In the last step, the semantic is incorrect as we need to apply filter on the data object. The data object ('end_time') was not called. Secondly, the formats for 'Date' is day/month/Year. By default, as.Date returns a Date class if the format is Year-month-day (YYYY-MM-DD). For all other formats, specify the format



          library(tidyverse)
          end_time %>%
          filter(dmy(end_time) < dmy("12/01/2018"))


          In the above code, we used dmy from lubridate package. If we use as.Date, it would be



          end_time %>%
          filter(as.Date(end_time, format = "%d/%m/%Y") < as.Date("2018-01-12"))





          share|improve this answer























          • How do i convert to 'Date'?
            – Jack Bell
            Nov 22 at 18:10










          • @JackBell Updated the post
            – akrun
            Nov 22 at 18:11











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436234%2fsort-column-by-date-after-it-is-in-my-environment-using-filter%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          We need to convert it to Date class. Based on the image and the OP's code, 'end_time' seems to be the column name and there is also an object created with the same name. In the last step, the semantic is incorrect as we need to apply filter on the data object. The data object ('end_time') was not called. Secondly, the formats for 'Date' is day/month/Year. By default, as.Date returns a Date class if the format is Year-month-day (YYYY-MM-DD). For all other formats, specify the format



          library(tidyverse)
          end_time %>%
          filter(dmy(end_time) < dmy("12/01/2018"))


          In the above code, we used dmy from lubridate package. If we use as.Date, it would be



          end_time %>%
          filter(as.Date(end_time, format = "%d/%m/%Y") < as.Date("2018-01-12"))





          share|improve this answer























          • How do i convert to 'Date'?
            – Jack Bell
            Nov 22 at 18:10










          • @JackBell Updated the post
            – akrun
            Nov 22 at 18:11
















          1














          We need to convert it to Date class. Based on the image and the OP's code, 'end_time' seems to be the column name and there is also an object created with the same name. In the last step, the semantic is incorrect as we need to apply filter on the data object. The data object ('end_time') was not called. Secondly, the formats for 'Date' is day/month/Year. By default, as.Date returns a Date class if the format is Year-month-day (YYYY-MM-DD). For all other formats, specify the format



          library(tidyverse)
          end_time %>%
          filter(dmy(end_time) < dmy("12/01/2018"))


          In the above code, we used dmy from lubridate package. If we use as.Date, it would be



          end_time %>%
          filter(as.Date(end_time, format = "%d/%m/%Y") < as.Date("2018-01-12"))





          share|improve this answer























          • How do i convert to 'Date'?
            – Jack Bell
            Nov 22 at 18:10










          • @JackBell Updated the post
            – akrun
            Nov 22 at 18:11














          1












          1








          1






          We need to convert it to Date class. Based on the image and the OP's code, 'end_time' seems to be the column name and there is also an object created with the same name. In the last step, the semantic is incorrect as we need to apply filter on the data object. The data object ('end_time') was not called. Secondly, the formats for 'Date' is day/month/Year. By default, as.Date returns a Date class if the format is Year-month-day (YYYY-MM-DD). For all other formats, specify the format



          library(tidyverse)
          end_time %>%
          filter(dmy(end_time) < dmy("12/01/2018"))


          In the above code, we used dmy from lubridate package. If we use as.Date, it would be



          end_time %>%
          filter(as.Date(end_time, format = "%d/%m/%Y") < as.Date("2018-01-12"))





          share|improve this answer














          We need to convert it to Date class. Based on the image and the OP's code, 'end_time' seems to be the column name and there is also an object created with the same name. In the last step, the semantic is incorrect as we need to apply filter on the data object. The data object ('end_time') was not called. Secondly, the formats for 'Date' is day/month/Year. By default, as.Date returns a Date class if the format is Year-month-day (YYYY-MM-DD). For all other formats, specify the format



          library(tidyverse)
          end_time %>%
          filter(dmy(end_time) < dmy("12/01/2018"))


          In the above code, we used dmy from lubridate package. If we use as.Date, it would be



          end_time %>%
          filter(as.Date(end_time, format = "%d/%m/%Y") < as.Date("2018-01-12"))






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 at 18:10

























          answered Nov 22 at 18:06









          akrun

          396k13187260




          396k13187260












          • How do i convert to 'Date'?
            – Jack Bell
            Nov 22 at 18:10










          • @JackBell Updated the post
            – akrun
            Nov 22 at 18:11


















          • How do i convert to 'Date'?
            – Jack Bell
            Nov 22 at 18:10










          • @JackBell Updated the post
            – akrun
            Nov 22 at 18:11
















          How do i convert to 'Date'?
          – Jack Bell
          Nov 22 at 18:10




          How do i convert to 'Date'?
          – Jack Bell
          Nov 22 at 18:10












          @JackBell Updated the post
          – akrun
          Nov 22 at 18:11




          @JackBell Updated the post
          – akrun
          Nov 22 at 18:11


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436234%2fsort-column-by-date-after-it-is-in-my-environment-using-filter%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What visual should I use to simply compare current year value vs last year in Power BI desktop

          Alexandru Averescu

          Trompette piccolo