在哪里可以找到在R

问题描述 投票:0回答:1

当寻找一种将角色转换为r的方法时,我遇到了这一点:

为什么我在橄榄酸日期的功能是如此慢? 具有以下代码:

fmt <- "%F"

,后来用于指定格式1984-04-21 in

data.table::as.IDate(chr_dates, fmt)
.
。
r-help没有给我一个答案,我终于在这里找到了一个:
STATSCODES.com

但是该网站看上去对我看上去很好,但似乎是由一个人维护的。 因此,我的问题,因为我希望迟早会遇到其他案件: 有一个全面的格式符号列表(最好是公开维护),或者是在r?
中找到此类符号的definitiosn的方法

请参阅
%F

(或

Here

r formatting date-conversion
1个回答
0
投票
格式的详细信息是特定于平台的,但以下内容可能广泛可用:大多数是由POSIX标准定义的。转换规范由%引入,通常是一个字母或O或E,然后是一个字母。格式字符串中的任何字符都不是转换规范的一部分(%%给出%)。广泛实施的转换规范包括

%a
help("strptime")

%a

Abbreviated weekday name in the current locale on this platform. (Also matches full name on input: in some locales there are no abbreviations of names.)

%b
Full weekday name in the current locale. (Also matches abbreviated name on input.)

%b
Abbreviated month name in the current locale on this platform. (Also matches full name on input: in some locales there are no abbreviations of names.)

%c
Full month name in the current locale. (Also matches abbreviated name on input.)

%c
Date and time. Locale-specific on output, "%a %b %e %H:%M:%S %Y" on input.

%d
Century (00–99): the integer part of the year divided by 100.

%d
Day of the month as decimal number (01–31).

%e
Date format such as %m/%d/%y: the C99 standard says it should be that exact format (but not all OSes comply).

%f
Day of the month as decimal number (1–31), with a leading space for a single-digit number.

%g
Equivalent to %Y-%m-%d (the ISO 8601 date format).

%g
The last two digits of the week-based year (see %V). (Accepted but ignored on input.)

%h
The week-based year (see %V) as a decimal number. (Accepted but ignored on input.)

%h
Equivalent to %b.

%i
Hours as decimal number (00–23). As a special exception strings such as ‘⁠24:00:00⁠’ are accepted for input, since ISO 8601 allows these.

%j
Hours as decimal number (01–12).

%m
Day of year as decimal number (001–366): For input, 366 is only valid in a leap year.

%m
Month as decimal number (01–12).

%n
Minute as decimal number (00–59).

%p
Newline on output, arbitrary whitespace on input.

%r
AM/PM indicator in the locale. Used in conjunction with %I and not with %H. An empty string in some locales (for example on some OSes, non-English European locales including Russia). The behaviour is undefined if used for input in such a locale.

Some platforms accept %P for output, which uses a lower-case version (%p may also use lower case): others will output P.

%r
For output, the 12-hour clock time (using the locale's AM or PM): only defined in some locales, and on some OSes misleading in locales which do not define an AM/PM indicator. For input, equivalent to %I:%M:%S %p.

%s
Equivalent to %H:%M.

%t
Second as integer (00–61), allowing for up to two leap-seconds (but POSIX-compliant implementations will ignore leap seconds).

%t
Tab on output, arbitrary whitespace on input.

%u
Equivalent to %H:%M:%S.

%u
Weekday as a decimal number (1–7, Monday is 1).

%v
Week of the year as decimal number (00–53) using Sunday as the first day 1 of the week (and typically with the first Sunday of the year as day 1 of week 1). The US convention.

%w
Week of the year as decimal number (01–53) as defined in ISO 8601. If the week (starting on Monday) containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. See %G (%g) for the year corresponding to the week given by %V. (Accepted but ignored on input.)

%w
Weekday as decimal number (0–6, Sunday is 0).

%x
Week of the year as decimal number (00–53) using Monday as the first day of week (and typically with the first Monday of the year as day 1 of week 1). The UK convention.

%x
Date. Locale-specific on output, "%y/%m/%d" on input.

%y
Time. Locale-specific on output, "%H:%M:%S" on input.

%y
Year without century (00–99). On input, values 00 to 68 are prefixed by 20 and 69 to 99 by 19 – that is the behaviour specified by the 2018 POSIX standard, but it does also say ‘it is expected that in a future version the default century inferred from a 2-digit year will change’.

%z
Year with century. Note that whereas there was no zero in the original Gregorian calendar, ISO 8601:2004 defines it to be valid (interpreted as 1BC): see https://en.wikipedia.org/wiki/0_(year). However, the standards also say that years before 1582 in its calendar should only be used with agreement of the parties involved.

For input, only years 0:9999 are accepted.

%z
Signed offset in hours and minutes from UTC, so -0800 is 8 hours behind UTC. (Standard only for output. For input R currently supports it on all platforms – values from -1400 to +1400 are accepted.)

在哪里显示领先的零将用于输出,但输入时是可选的。名称在输入上是对案例匹配的:它们是否在输出上大写取决于平台和语言环境。请注意,缩写名称是特定于平台的(尽管标准表明在“u2060cu2060”语言环境中,它们必须是大写英语名称的前三个字母:该约定在英语语言环境中广泛使用,例如,法国月份的缩写在Linux,Macos,Solaris和Windows的任何两个中都不相同。如果您希望使用%a,%b或%h作为输入格式的一部分,那么知道缩写是什么:请参阅示例以了解如何检查。
当%z或%z用于带有分配时区的对象的输出时,尝试使用该时区的值 - 但不能保证成功。
对于%n和%t的“空格”的定义是依赖平台的:对于大多数人来说,它不包括非破坏空间。

在标准方面,没有规模较少的是

%k

(Output only.) Time zone abbreviation as a character string (empty if not available). This may not be reliable when a time zone has changed abbreviations over the years.

%l

The 24-hour clock time with single digits preceded by a blank.

%s

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.