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

Work requires me to come in early to start computer but wont let me clock in to get paid for it

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

How much of a wave function must reside inside event horizon for it to be consumed by the black hole?

How bug prioritization works in agile projects vs non agile

Creating a chemical industry from a medieval tech level without petroleum

A strange hotel

Contradiction proof for inequality of P and NP?

"The cow" OR "a cow" OR "cows" in this context

How do I reattach a shelf to the wall when it ripped out of the wall?

Is Diceware more secure than a long passphrase?

Can someone publish a story that happened to you?

Can a stored procedure reference the database in which it is stored?

Why do games have consumables?

A Paper Record is What I Hamper

Negative Resistance

Does a large simulator bay have standard public address announcements?

Is there a word for the censored part of a video?

Can I criticise the more senior developers around me for not writing clean code?

Do I need to watch Ant-Man and the Wasp and Captain Marvel before watching Avengers: Endgame?

What is the best way to deal with NPC-NPC combat?

Is there metaphorical meaning of "aus der Haft entlassen"?

Is there really no use for MD5 anymore?

Why must Chinese maps be obfuscated?

Extracting Dirichlet series coefficients



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

      141k23280363




      141k23280363










      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권, 지리지 충청도 공주목 은진현