Converting data to xts changes the timestamp dataHow to join (merge) data frames (inner, outer, left, right)Drop data frame columns by nameChanging column names of a data frameHow to calculate daily means, medians, from weather variables data collected hourly in R?create timeseries based on start and end dateR date origin for time in secondsARIMA ForecastingExtract day and month from dateHow to create full date column using “Month_Year” character string and join three different data frames ordered by the date column in Ri am preparing time series data for building a rnn

Working in the USA for living expenses only; allowed on VWP?

Word for a small burst of laughter that can't be held back

What's the correct term for a waitress in the Middle Ages?

Is having a hidden directory under /etc safe?

The term for the person/group a political party aligns themselves with to appear concerned about the general public

Can I ask a publisher for a paper that I need for reviewing

Is it legal in the UK for politicians to lie to the public for political gain?

Explain Ant-Man's "not it" scene from Avengers: Endgame

Rotated Position of Integers

Opposite of "Squeaky wheel gets the grease"

How to split a string in two substrings of same length using bash?

Could the Missouri River be running while Lake Michigan was frozen several meters deep?

Could a guilty Boris Johnson be used to cancel Brexit?

Unconventional Opposites

Does Peach's float negate shorthop knockback multipliers?

Can an old DSLR be upgraded to match modern smartphone image quality

What is a simple, physical situation where complex numbers emerge naturally?

How do I remove hundreds of automatically added network printers?

Can a magnetic field of a large body be stronger than its gravity?

Did Darth Vader wear the same suit for 20+ years?

Applicants clearly not having the skills they advertise

pitch and volume compensations for different instruments

Why does a helium balloon rise?

Restoring order in a deck of playing cards (II)



Converting data to xts changes the timestamp data


How to join (merge) data frames (inner, outer, left, right)Drop data frame columns by nameChanging column names of a data frameHow to calculate daily means, medians, from weather variables data collected hourly in R?create timeseries based on start and end dateR date origin for time in secondsARIMA ForecastingExtract day and month from dateHow to create full date column using “Month_Year” character string and join three different data frames ordered by the date column in Ri am preparing time series data for building a rnn






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am currently doing research on soil moisture and have to get hourly and daily means from my time series data.



When I convert the dataframe into an xts object, the time series changes and I can't figure out why.



The data in the data frame looks like this:



 time MC temp

1 2018-06-27 11:30:00 17.1 15.8

2 2018-06-27 11:45:00 17.0 15.8

3 2018-06-27 12:00:00 17.0 15.8

4 2018-06-27 12:15:00 17.0 15.9

5 2018-06-27 12:30:00 17.2 15.9

6 2018-06-27 12:45:00 17.0 16.0


But when I convert it, the time stamp begins at 2018-01-09 00:00 and proceeds to make 5 min time increments. This is the code I am using:



sm_xts <- xts(sm.data[,2:3], as.Date(sm.data$time))
sm_zoo <- read.zoo(sm.data, index.column = 1)
dat_xts <- as.xts(sm_zoo)


I have already converted the time stamp to a as.POSIXct class and checked for duplicates in my time series.



> anyDuplicated(sm.data$time)
[1] 0









share|improve this question






























    0















    I am currently doing research on soil moisture and have to get hourly and daily means from my time series data.



    When I convert the dataframe into an xts object, the time series changes and I can't figure out why.



    The data in the data frame looks like this:



     time MC temp

    1 2018-06-27 11:30:00 17.1 15.8

    2 2018-06-27 11:45:00 17.0 15.8

    3 2018-06-27 12:00:00 17.0 15.8

    4 2018-06-27 12:15:00 17.0 15.9

    5 2018-06-27 12:30:00 17.2 15.9

    6 2018-06-27 12:45:00 17.0 16.0


    But when I convert it, the time stamp begins at 2018-01-09 00:00 and proceeds to make 5 min time increments. This is the code I am using:



    sm_xts <- xts(sm.data[,2:3], as.Date(sm.data$time))
    sm_zoo <- read.zoo(sm.data, index.column = 1)
    dat_xts <- as.xts(sm_zoo)


    I have already converted the time stamp to a as.POSIXct class and checked for duplicates in my time series.



    > anyDuplicated(sm.data$time)
    [1] 0









    share|improve this question


























      0












      0








      0








      I am currently doing research on soil moisture and have to get hourly and daily means from my time series data.



      When I convert the dataframe into an xts object, the time series changes and I can't figure out why.



      The data in the data frame looks like this:



       time MC temp

      1 2018-06-27 11:30:00 17.1 15.8

      2 2018-06-27 11:45:00 17.0 15.8

      3 2018-06-27 12:00:00 17.0 15.8

      4 2018-06-27 12:15:00 17.0 15.9

      5 2018-06-27 12:30:00 17.2 15.9

      6 2018-06-27 12:45:00 17.0 16.0


      But when I convert it, the time stamp begins at 2018-01-09 00:00 and proceeds to make 5 min time increments. This is the code I am using:



      sm_xts <- xts(sm.data[,2:3], as.Date(sm.data$time))
      sm_zoo <- read.zoo(sm.data, index.column = 1)
      dat_xts <- as.xts(sm_zoo)


      I have already converted the time stamp to a as.POSIXct class and checked for duplicates in my time series.



      > anyDuplicated(sm.data$time)
      [1] 0









      share|improve this question
















      I am currently doing research on soil moisture and have to get hourly and daily means from my time series data.



      When I convert the dataframe into an xts object, the time series changes and I can't figure out why.



      The data in the data frame looks like this:



       time MC temp

      1 2018-06-27 11:30:00 17.1 15.8

      2 2018-06-27 11:45:00 17.0 15.8

      3 2018-06-27 12:00:00 17.0 15.8

      4 2018-06-27 12:15:00 17.0 15.9

      5 2018-06-27 12:30:00 17.2 15.9

      6 2018-06-27 12:45:00 17.0 16.0


      But when I convert it, the time stamp begins at 2018-01-09 00:00 and proceeds to make 5 min time increments. This is the code I am using:



      sm_xts <- xts(sm.data[,2:3], as.Date(sm.data$time))
      sm_zoo <- read.zoo(sm.data, index.column = 1)
      dat_xts <- as.xts(sm_zoo)


      I have already converted the time stamp to a as.POSIXct class and checked for duplicates in my time series.



      > anyDuplicated(sm.data$time)
      [1] 0






      r time-series xts






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 12:31









      Joshua Ulrich

      143k24282366




      143k24282366










      asked Mar 22 at 16:32









      Danielle CrawfordDanielle Crawford

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Maybe you have some problems with your initial data input process.



           df
          # time MC temp
          # 1 2018-06-27 11:30:00 17.1 15.8
          # 2 2018-06-27 11:45:00 17.0 15.8
          # 3 2018-06-27 12:00:00 17.0 15.8
          # 4 2018-06-27 12:15:00 17.0 15.9
          # 5 2018-06-27 12:30:00 17.2 15.9
          # 6 2018-06-27 12:45:00 17.0 16.0


          Now the date and time values are stored in a single variable as a char



          str(df$time)
          # chr [1:6] "2018-06-27 11:30:00" "2018-06-27 11:45:00" ...


          Let's convert it into real date and time so as not to lose time information:



          strptime(df$time, "%Y-%m-%d %H:%M:%S")
          # [1] "2018-06-27 11:30:00 EEST" "2018-06-27 11:45:00 EEST"
          # [3] "2018-06-27 12:00:00 EEST" "2018-06-27 12:15:00 EEST"
          # [5] "2018-06-27 12:30:00 EEST" "2018-06-27 12:45:00 EEST"


          Seems like it works. The possible problems with timezone are beyond the scope of this answer.



          Now let's convert the data frame to xts. In the finished xts, we do not need date and time in the symbolic form. So we exclude the first column.



          df2xts <- xts(df[,2:3], order.by=strptime(df$time, "%Y-%m-%d %H:%M:%S"))
          df2xts
          # time MC temp
          # 1 2018-06-27 11:30:00 17.1 15.8
          # 2 2018-06-27 11:45:00 17.0 15.8
          # 3 2018-06-27 12:00:00 17.0 15.8
          # 4 2018-06-27 12:15:00 17.0 15.9
          # 5 2018-06-27 12:30:00 17.2 15.9
          # 6 2018-06-27 12:45:00 17.0 16.0





          share|improve this answer

























            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%2f55304037%2fconverting-data-to-xts-changes-the-timestamp-data%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









            0














            Maybe you have some problems with your initial data input process.



             df
            # time MC temp
            # 1 2018-06-27 11:30:00 17.1 15.8
            # 2 2018-06-27 11:45:00 17.0 15.8
            # 3 2018-06-27 12:00:00 17.0 15.8
            # 4 2018-06-27 12:15:00 17.0 15.9
            # 5 2018-06-27 12:30:00 17.2 15.9
            # 6 2018-06-27 12:45:00 17.0 16.0


            Now the date and time values are stored in a single variable as a char



            str(df$time)
            # chr [1:6] "2018-06-27 11:30:00" "2018-06-27 11:45:00" ...


            Let's convert it into real date and time so as not to lose time information:



            strptime(df$time, "%Y-%m-%d %H:%M:%S")
            # [1] "2018-06-27 11:30:00 EEST" "2018-06-27 11:45:00 EEST"
            # [3] "2018-06-27 12:00:00 EEST" "2018-06-27 12:15:00 EEST"
            # [5] "2018-06-27 12:30:00 EEST" "2018-06-27 12:45:00 EEST"


            Seems like it works. The possible problems with timezone are beyond the scope of this answer.



            Now let's convert the data frame to xts. In the finished xts, we do not need date and time in the symbolic form. So we exclude the first column.



            df2xts <- xts(df[,2:3], order.by=strptime(df$time, "%Y-%m-%d %H:%M:%S"))
            df2xts
            # time MC temp
            # 1 2018-06-27 11:30:00 17.1 15.8
            # 2 2018-06-27 11:45:00 17.0 15.8
            # 3 2018-06-27 12:00:00 17.0 15.8
            # 4 2018-06-27 12:15:00 17.0 15.9
            # 5 2018-06-27 12:30:00 17.2 15.9
            # 6 2018-06-27 12:45:00 17.0 16.0





            share|improve this answer





























              0














              Maybe you have some problems with your initial data input process.



               df
              # time MC temp
              # 1 2018-06-27 11:30:00 17.1 15.8
              # 2 2018-06-27 11:45:00 17.0 15.8
              # 3 2018-06-27 12:00:00 17.0 15.8
              # 4 2018-06-27 12:15:00 17.0 15.9
              # 5 2018-06-27 12:30:00 17.2 15.9
              # 6 2018-06-27 12:45:00 17.0 16.0


              Now the date and time values are stored in a single variable as a char



              str(df$time)
              # chr [1:6] "2018-06-27 11:30:00" "2018-06-27 11:45:00" ...


              Let's convert it into real date and time so as not to lose time information:



              strptime(df$time, "%Y-%m-%d %H:%M:%S")
              # [1] "2018-06-27 11:30:00 EEST" "2018-06-27 11:45:00 EEST"
              # [3] "2018-06-27 12:00:00 EEST" "2018-06-27 12:15:00 EEST"
              # [5] "2018-06-27 12:30:00 EEST" "2018-06-27 12:45:00 EEST"


              Seems like it works. The possible problems with timezone are beyond the scope of this answer.



              Now let's convert the data frame to xts. In the finished xts, we do not need date and time in the symbolic form. So we exclude the first column.



              df2xts <- xts(df[,2:3], order.by=strptime(df$time, "%Y-%m-%d %H:%M:%S"))
              df2xts
              # time MC temp
              # 1 2018-06-27 11:30:00 17.1 15.8
              # 2 2018-06-27 11:45:00 17.0 15.8
              # 3 2018-06-27 12:00:00 17.0 15.8
              # 4 2018-06-27 12:15:00 17.0 15.9
              # 5 2018-06-27 12:30:00 17.2 15.9
              # 6 2018-06-27 12:45:00 17.0 16.0





              share|improve this answer



























                0












                0








                0







                Maybe you have some problems with your initial data input process.



                 df
                # time MC temp
                # 1 2018-06-27 11:30:00 17.1 15.8
                # 2 2018-06-27 11:45:00 17.0 15.8
                # 3 2018-06-27 12:00:00 17.0 15.8
                # 4 2018-06-27 12:15:00 17.0 15.9
                # 5 2018-06-27 12:30:00 17.2 15.9
                # 6 2018-06-27 12:45:00 17.0 16.0


                Now the date and time values are stored in a single variable as a char



                str(df$time)
                # chr [1:6] "2018-06-27 11:30:00" "2018-06-27 11:45:00" ...


                Let's convert it into real date and time so as not to lose time information:



                strptime(df$time, "%Y-%m-%d %H:%M:%S")
                # [1] "2018-06-27 11:30:00 EEST" "2018-06-27 11:45:00 EEST"
                # [3] "2018-06-27 12:00:00 EEST" "2018-06-27 12:15:00 EEST"
                # [5] "2018-06-27 12:30:00 EEST" "2018-06-27 12:45:00 EEST"


                Seems like it works. The possible problems with timezone are beyond the scope of this answer.



                Now let's convert the data frame to xts. In the finished xts, we do not need date and time in the symbolic form. So we exclude the first column.



                df2xts <- xts(df[,2:3], order.by=strptime(df$time, "%Y-%m-%d %H:%M:%S"))
                df2xts
                # time MC temp
                # 1 2018-06-27 11:30:00 17.1 15.8
                # 2 2018-06-27 11:45:00 17.0 15.8
                # 3 2018-06-27 12:00:00 17.0 15.8
                # 4 2018-06-27 12:15:00 17.0 15.9
                # 5 2018-06-27 12:30:00 17.2 15.9
                # 6 2018-06-27 12:45:00 17.0 16.0





                share|improve this answer















                Maybe you have some problems with your initial data input process.



                 df
                # time MC temp
                # 1 2018-06-27 11:30:00 17.1 15.8
                # 2 2018-06-27 11:45:00 17.0 15.8
                # 3 2018-06-27 12:00:00 17.0 15.8
                # 4 2018-06-27 12:15:00 17.0 15.9
                # 5 2018-06-27 12:30:00 17.2 15.9
                # 6 2018-06-27 12:45:00 17.0 16.0


                Now the date and time values are stored in a single variable as a char



                str(df$time)
                # chr [1:6] "2018-06-27 11:30:00" "2018-06-27 11:45:00" ...


                Let's convert it into real date and time so as not to lose time information:



                strptime(df$time, "%Y-%m-%d %H:%M:%S")
                # [1] "2018-06-27 11:30:00 EEST" "2018-06-27 11:45:00 EEST"
                # [3] "2018-06-27 12:00:00 EEST" "2018-06-27 12:15:00 EEST"
                # [5] "2018-06-27 12:30:00 EEST" "2018-06-27 12:45:00 EEST"


                Seems like it works. The possible problems with timezone are beyond the scope of this answer.



                Now let's convert the data frame to xts. In the finished xts, we do not need date and time in the symbolic form. So we exclude the first column.



                df2xts <- xts(df[,2:3], order.by=strptime(df$time, "%Y-%m-%d %H:%M:%S"))
                df2xts
                # time MC temp
                # 1 2018-06-27 11:30:00 17.1 15.8
                # 2 2018-06-27 11:45:00 17.0 15.8
                # 3 2018-06-27 12:00:00 17.0 15.8
                # 4 2018-06-27 12:15:00 17.0 15.9
                # 5 2018-06-27 12:30:00 17.2 15.9
                # 6 2018-06-27 12:45:00 17.0 16.0






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 5 at 21:42

























                answered Apr 5 at 7:42









                user3139228user3139228

                265




                265





























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304037%2fconverting-data-to-xts-changes-the-timestamp-data%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현