R语言 : 读取csv 文件, 画基金净值线
来源:互联网 发布:杰奇网络账号注册 编辑:程序博客网 时间:2024/05/01 05:49
数据文件 66001.txt 内容格式:
date1,jz0,jz1,jz2,jz3,jz4,jz5
2017-09-01,1.0202,1.6531,2.4647,1.1081,NA,2.9068
2017-09-04,1.0134,1.6621,2.4576,1.1083,NA,2.8983
2017-09-05,1.0168,1.6637,2.4616,1.1085,NA,2.9010
... ...
xts 是基于 zoo 的时间序列
xts_funds.R 代码:
library(xts)setwd("D:/test")data <- read.csv("66001.txt", header=TRUE, sep=",")class(data)head(data)dates <- as.Date(data$date1, "%Y-%m-%d")attach(data)plot(dates,jz0, type="l", lwd=1, main="基金净值图", xlab="日期",ylab="净值",ylim=c(0.5,4.0));lines(dates,jz1, type="l", lwd=1, col="blue")lines(dates,jz2, type="l", lwd=1, col="green")lines(dates,jz3, type="l", lwd=1, col="yellow")lines(dates,jz4, type="l", lwd=1, col="red")lines(dates,jz5, type="l", lwd=1, col="purple")grid()detach(data)jjdm <- c("660010","660011","660012","660013","660014","660015")color <- c("black","blue","green","yellow","red","purple")legend("topleft", jjdm, pch=c(0,0,0,0,0,0), col=color, cex=0.6); # 图例
参考书: [ R in Action 第2版 ] 第3章 图形初阶 : 3.5 图形的组合
xts_fund6.R 代码:
library(xts)setwd("D:/test")data <- read.csv("66001.txt", header=TRUE, sep=",")class(data)dates <- as.Date(data$date1, "%Y-%m-%d")attach(data)opar <- par(no.readonly=TRUE)par(mfrow= c(2,3), oma= c(0,0, 3,0)) # 2行3列plot(dates, jz0, type="l", lwd=1, main="660010", xlab="date", ylab="value", col="black")text(x=200, y=200, labels="fund net value")grid()plot(dates, jz1, type="l", lwd=1, main="660011", xlab="date", ylab="value", col="blue")grid()plot(dates, jz2, type="l", lwd=1, main="660012", xlab="date", ylab="value", col="green")grid()plot(dates, jz3, type="l", lwd=1, main="660013", xlab="date", ylab="value", col="yellow")grid()plot(dates, jz4, type="l", lwd=1, main="660014", xlab="date", ylab="value", col="red")grid()plot(dates, jz5, type="l", lwd=1, main="660015", xlab="date", ylab="value", col="purple")grid()mtext("6个基金净值图", side=3, line=0, outer=T) # 总的标题par(opar)detach(data)
阅读全文
0 0
- R语言 : 读取csv 文件, 画基金净值线
- gnuplot : 读取csv 文件, 画基金净值线
- python : pandas 读取csv 文件, matplotlib 画基金净值线
- R语言读取csv文件
- R语言读取csv文件出错
- R语言读取csv中的内容
- R语言读取文件
- C语言读取CSV文件
- C语言读取csv文件
- R语言读CSV、txt文件方式以及read.table read.csv 和readr(大数据读取包)
- R语言读CSV、txt文件方式以及read.table read.csv 和readr(大数据读取包)
- R语言读CSV、txt文件方式以及read.table read.csv 和readr(大数据读取包)
- R语言读取Excel文件
- R语言读取Excel文件
- R语言读取网站文件
- R语言读取文件数据
- R语言读取xlsx文件
- R语言之读取Excel及csv数据
- 关于跨域访问的扯淡
- 我有一个还在蹒跚学步的小孩是否应该学习Python?
- Python正则表达式
- modbus通信协议中的功能码、异常功能码和错误码
- bzoj 4424: Cf19E Fairy
- R语言 : 读取csv 文件, 画基金净值线
- (二)常量定义
- 全志A20编译&调试笔记
- college English test band six
- Tomcat安装步骤
- 数据结构——链表之单链表重复元素的删除
- java I/O思维导图
- hihocoder#1093 : 最短路径·三:SPFA算法
- 树链剖分