我有股票价格数据(数据)。股票数据我想将其可视化。我首先使用 ggplot R 绘图来可视化该系列。
Date Closed
2010-07-19 0.0808
2010-07-20 0.7547
Run Code Online (Sandbox Code Playgroud)
当我使用下面的代码时
my_date_format <- function()
{
function(x)
{
m <- format(x,"%b")
y <- format(x,"%Y")
ifelse(duplicated(y),m,paste(m,y))
}
}
ggplot(data, aes(x=Date, z=Closed)) +
geom_point() +
scale_x_datetime(breaks = date_breaks("1 month"), labels=my_date_format())
Run Code Online (Sandbox Code Playgroud)
我有一个错误:错误:无效输入:time_trans 仅适用于 POSIXct 类的对象
当然,我尝试将 Date 更改为 Date 格式,但它也不起作用。我也试过
ggplot(data, aes(Date, Closed)) + geom_line() +
scale_x_date(format = "%Y-%m-%d") + xlab("") + ylab("Closed")
or
ggplot(data,aes(Date,Closed))+geom_line() + scale_x_date(breaks = “1 month”,labels=date_format(“%b/%y”)) +xlab(” “) + ylab(“closed”)
Run Code Online (Sandbox Code Playgroud)
我有这样的数据
X3 X4 X5 X6 X7 X24 X25 X26 X39 X40 X41 X54 X55 X56 X69 X70 X71
1 step1 step2 step3 step4 step10 step2 step3 step4 step10 step10 step10 step10 step10 step10 step10 step10 step10
Run Code Online (Sandbox Code Playgroud)
我想删除重复的列。所以期望的输出是
X3 X4 X5 X6 X7
1 step1 step2 step3 step4 step10
Run Code Online (Sandbox Code Playgroud)