我一直在努力阅读数据集并使用readr
解析正确的日期格式。我的数据如下:
short_name full_name month Euro
Jan January 1 10
Feb February 2 20
Mar March 3 30
Apr April 4 40
May May 5 50
Jun June 6 60
我想要做的是一个月声明前三列(short_name,full_name,month),以便稍后我可以使用它们在ggplot中绘图。
Variant_1:在这里我尝试读入数据并声明它
read_csv2(file = "abc.csv", col_names = TRUE, col_types = cols(short_name = col_date(format = ("%b")),
full_name = col_date("%B"),
month = col_date(format = "%m"),
Euro = col_integer()))
Variant_2:在这里我尝试将数据作为字符读入,然后解析正确的格式
read_tsv("abc.txt", col_names = T, col_types = cols(short_name = col_character(),
full_name = col_character(),
month = col_character(),
Euro = col_character()))
parse_datetime(abc$full_name, format = "%B", locale = ("en_US"))
到目前为止,他们都没有工作,我收到了很多不同的错误。是否甚至可以单独使用"%B"
和"%b"
以及"%m"
来声明数据集?