Using r language to draw a simple time series diagram

Source: Internet
Author: User

The R language cannot automatically convert the read data into a time series format,

So a key step in using R language to draw a time series diagram is to convert the data read into a time series format,

The following is a simple program:

#  read data, first convert Excel format to CSV format and then read
h <-read.table (file = "D:/data/50etfx1.csv", Sep = ",", Header = T)
 #
  
    Convert the data format into the time series format
Library (XTS)  # Load the required package
hh <-xts (h$x1, as. Date (H$time, format= '%y/%m/%d ')) 
  #  Draw
   # Specify the length of the graph or  draw directly with command Plot (HH)
win.graph (width = 9.5 , height = 4.5,pointsize = 8)
plot (Hh,type = ' l ', main= ')
  
The effect is as follows:


The data format used by the sample program is as follows:


Time X1
2013/2/5 on 0.000000
2013/2/6 on 0.007236
2013/2/7-0.011708
2013/2/8-0.004989
2013/2/18-0.010806
2013/2/19-0.015255
2013/2/20-0.001583
2013/2/21-0.040148

。。。。。。。。。。。。

2015/1/29-0.019893
2015/1/30-0.016171
2015/2/2-0.031637
2015/2/3 on 0.027171
2015/2/4-0.015722
2015/2/5-0.010018
2015/2/6-0.012613


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.