楼主: oscaryun
11475 2

[问答] 新人求助日期格式问题 [推广有奖]

  • 0关注
  • 0粉丝

大专生

78%

还不是VIP/贵宾

-

威望
0
论坛币
7 个
通用积分
0.1000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
359 点
帖子
13
精华
0
在线时间
107 小时
注册时间
2006-5-9
最后登录
2024-7-2

楼主
oscaryun 发表于 2016-3-30 15:23:09 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
想做一个年-月的时间直方统计如下:
> test<-as.Date("2008-12-19")
> test
[1] "2008-12-19"
> str(test)
Date[1:1], format: "2008-12-19"
> test1<-strftime(test,format = "%Y-%m")
> test1
[1] "2008-12"
> str(test1)
chr "2008-12"
> test2<-as.Date(test1)
Error in charToDate(x) : 字符串的格式不够标准明确
> test3<-strftime(test,format="%Y")
> test3
[1] "2008"
> str(test3)
chr "2008"

年-月-日转换成年-月或年后格式就不是Date型而是变成了chr型,原来年-月-日Date型时可以用geom_histogram直接对时间做直方统计,转换成后年-月或年chr型后就不行了,报错如下:
Error: StatBin requires a continuous x variable the x variable is discrete. Perhaps you want stat="count"?
该如何解决?

另外我用年-月-日做直方统计时提示信息如下:
stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
这个binwidth是指的30日吗?
谢谢大家
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Continuous histogram Variable requires Discrete continuous Error 统计

沙发
qoiqpwqr 发表于 2016-3-30 20:11:06
可以用zoo包里的as.yearmon
已有 1 人评分学术水平 收起 理由
万人往LVR + 3 精彩帖子

总评分: 学术水平 + 3   查看全部评分

藤椅
oscaryun 发表于 2016-3-31 21:43:23
qoiqpwqr 发表于 2016-3-30 20:11
可以用zoo包里的as.yearmon
好的谢谢。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 02:07