Remove part of the string in R - dropping some words from it2019 Community Moderator ElectionRemove specific words containing dots from a string

Why are on-board computers allowed to change controls without notifying the pilots?

How does it work when somebody invests in my business?

Everything Bob says is false. How does he get people to trust him?

What will be the benefits of Brexit?

Was Spock the First Vulcan in Starfleet?

Why is delta-v is the most useful quantity for planning space travel?

Was the picture area of a CRT a parallelogram (instead of a true rectangle)?

Failed to fetch jessie backports repository

Star/Wye electrical connection math symbol

Why did Kant, Hegel, and Adorno leave some words and phrases in the Greek alphabet?

How can I use the arrow sign in my bash prompt?

Your magic is very sketchy

Can I Retrieve Email Addresses from BCC?

Valid Badminton Score?

Where in the Bible does the greeting ("Dominus Vobiscum") used at Mass come from?

Why does John Bercow say “unlock” after reading out the results of a vote?

Lay out the Carpet

What is the opposite of 'gravitas'?

Modulo 2 binary long division in European notation

apt-get update is failing in debian

What is the term when two people sing in harmony, but they aren't singing the same notes?

Is it correct to write "is not focus on"?

Is there an Impartial Brexit Deal comparison site?

Personal Teleportation as a Weapon



Remove part of the string in R - dropping some words from it



2019 Community Moderator ElectionRemove specific words containing dots from a string










0












$begingroup$


I have a column in dataframe which should represent the date, named "taken", and looks like this:



taken



Sat Jan 01 15:30:27 CET 2011



Thu Jan 06 00:54:26 CET 2011



Sat Jan 08 19:49:02 CET 2011



Sun Jan 16 09:57:16 CET 2011



etc (more than 30000 rows)



Now, I need to change class from factor to date, but I haven't found solution for this kind of format. Since it would be easier with date looking like this:



taken



Jan 01 2011



Jan 06 2011



Jan 08 2011



Jan 16 2011



...How could I drop some words from a string (obviously, Mon/Tue... time and CET in this case) to change it into date?










share|improve this question







New contributor




Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    0












    $begingroup$


    I have a column in dataframe which should represent the date, named "taken", and looks like this:



    taken



    Sat Jan 01 15:30:27 CET 2011



    Thu Jan 06 00:54:26 CET 2011



    Sat Jan 08 19:49:02 CET 2011



    Sun Jan 16 09:57:16 CET 2011



    etc (more than 30000 rows)



    Now, I need to change class from factor to date, but I haven't found solution for this kind of format. Since it would be easier with date looking like this:



    taken



    Jan 01 2011



    Jan 06 2011



    Jan 08 2011



    Jan 16 2011



    ...How could I drop some words from a string (obviously, Mon/Tue... time and CET in this case) to change it into date?










    share|improve this question







    New contributor




    Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      0












      0








      0





      $begingroup$


      I have a column in dataframe which should represent the date, named "taken", and looks like this:



      taken



      Sat Jan 01 15:30:27 CET 2011



      Thu Jan 06 00:54:26 CET 2011



      Sat Jan 08 19:49:02 CET 2011



      Sun Jan 16 09:57:16 CET 2011



      etc (more than 30000 rows)



      Now, I need to change class from factor to date, but I haven't found solution for this kind of format. Since it would be easier with date looking like this:



      taken



      Jan 01 2011



      Jan 06 2011



      Jan 08 2011



      Jan 16 2011



      ...How could I drop some words from a string (obviously, Mon/Tue... time and CET in this case) to change it into date?










      share|improve this question







      New contributor




      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I have a column in dataframe which should represent the date, named "taken", and looks like this:



      taken



      Sat Jan 01 15:30:27 CET 2011



      Thu Jan 06 00:54:26 CET 2011



      Sat Jan 08 19:49:02 CET 2011



      Sun Jan 16 09:57:16 CET 2011



      etc (more than 30000 rows)



      Now, I need to change class from factor to date, but I haven't found solution for this kind of format. Since it would be easier with date looking like this:



      taken



      Jan 01 2011



      Jan 06 2011



      Jan 08 2011



      Jan 16 2011



      ...How could I drop some words from a string (obviously, Mon/Tue... time and CET in this case) to change it into date?







      rstudio






      share|improve this question







      New contributor




      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Mar 20 at 16:17









      TimorcheTimorche

      1




      1




      New contributor




      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Timorche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

          I wouldn't use them as time at first place. What would I do:



          String <- "Sat Jan 01 15:30:27 CET 2011"



          As your dates have same number of elements in them we could just count what part of the String we would like to get.



          date <- substr(String, start = 5, stop = 10)



          year <- substr(String, start =25 , stop = 28)



          Attach them togheter



          final <- paste(date,year, sep = " ")



          as.Date(final, format = "%b %d %Y")



          Little bit more information about as.Date
          https://www.statmethods.net/input/dates.html
          I hope it helps you :)






          share|improve this answer








          New contributor




          Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$












            Your Answer





            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "557"
            ;
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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
            );



            );






            Timorche is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47685%2fremove-part-of-the-string-in-r-dropping-some-words-from-it%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












            $begingroup$

            I wouldn't use them as time at first place. What would I do:



            String <- "Sat Jan 01 15:30:27 CET 2011"



            As your dates have same number of elements in them we could just count what part of the String we would like to get.



            date <- substr(String, start = 5, stop = 10)



            year <- substr(String, start =25 , stop = 28)



            Attach them togheter



            final <- paste(date,year, sep = " ")



            as.Date(final, format = "%b %d %Y")



            Little bit more information about as.Date
            https://www.statmethods.net/input/dates.html
            I hope it helps you :)






            share|improve this answer








            New contributor




            Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            $endgroup$

















              1












              $begingroup$

              I wouldn't use them as time at first place. What would I do:



              String <- "Sat Jan 01 15:30:27 CET 2011"



              As your dates have same number of elements in them we could just count what part of the String we would like to get.



              date <- substr(String, start = 5, stop = 10)



              year <- substr(String, start =25 , stop = 28)



              Attach them togheter



              final <- paste(date,year, sep = " ")



              as.Date(final, format = "%b %d %Y")



              Little bit more information about as.Date
              https://www.statmethods.net/input/dates.html
              I hope it helps you :)






              share|improve this answer








              New contributor




              Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






              $endgroup$















                1












                1








                1





                $begingroup$

                I wouldn't use them as time at first place. What would I do:



                String <- "Sat Jan 01 15:30:27 CET 2011"



                As your dates have same number of elements in them we could just count what part of the String we would like to get.



                date <- substr(String, start = 5, stop = 10)



                year <- substr(String, start =25 , stop = 28)



                Attach them togheter



                final <- paste(date,year, sep = " ")



                as.Date(final, format = "%b %d %Y")



                Little bit more information about as.Date
                https://www.statmethods.net/input/dates.html
                I hope it helps you :)






                share|improve this answer








                New contributor




                Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                $endgroup$



                I wouldn't use them as time at first place. What would I do:



                String <- "Sat Jan 01 15:30:27 CET 2011"



                As your dates have same number of elements in them we could just count what part of the String we would like to get.



                date <- substr(String, start = 5, stop = 10)



                year <- substr(String, start =25 , stop = 28)



                Attach them togheter



                final <- paste(date,year, sep = " ")



                as.Date(final, format = "%b %d %Y")



                Little bit more information about as.Date
                https://www.statmethods.net/input/dates.html
                I hope it helps you :)







                share|improve this answer








                New contributor




                Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 2 days ago









                BhjiBhji

                111




                111




                New contributor




                Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Bhji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




















                    Timorche is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    Timorche is a new contributor. Be nice, and check out our Code of Conduct.












                    Timorche is a new contributor. Be nice, and check out our Code of Conduct.











                    Timorche is a new contributor. Be nice, and check out our Code of Conduct.














                    Thanks for contributing an answer to Data Science Stack Exchange!


                    • 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.

                    Use MathJax to format equations. MathJax reference.


                    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%2fdatascience.stackexchange.com%2fquestions%2f47685%2fremove-part-of-the-string-in-r-dropping-some-words-from-it%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