• R sprintf函数


    ------------恢复内容开始------------
    看到sprintf函数有点不明所以,原文如下

    为了用指定的格式数值型转换成字符型, 可以使用sprintf()函数, 其用法与C语言的sprintf()函数相似, 只不过是向量化的。例如
    sprintf('file%03d.txt', c(1, 99, 100))
    ## [1] "file001.txt" "file099.txt" "file100.txt"

    sprintf()

    Use C-style String Formatting Commands

    Description

    A wrapper for the C function sprintf, that returns a character vector containing a formatted combination of text and variable values.

    Usage

    sprintf(fmt, ...)
    gettextf(fmt, ..., domain = NULL)
    Arguments
    fmt 格式化字符串
    a character vector of format strings, each of up to 8192 bytes.

    ...
    values to be passed into fmt. Only logical, integer, real and character vectors are supported, but some coercion will be done: see the ‘Details’ section. Up to 100.

    domain
    see gettext.

    Details
    sprintf is a wrapper for the system sprintf C-library function. Attempts are made to check that the mode of the values passed match the format supplied, and R's special values (NA, Inf, -Inf and NaN) are handled correctly.

    gettextf is a convenience function which provides C-style string formatting with possible translation of the format string.

    The arguments (including fmt) are recycled if possible a whole number of times to the length of the longest, and then the formatting is done in parallel. Zero-length arguments are allowed and will give a zero-length result. All arguments are evaluated even if unused, and hence some types (e.g., "symbol" or "language", see typeof) are not allowed.

    The following is abstracted from Kernighan and Ritchie (see References): however the actual implementation will follow the C99 standard and fine details (especially the behaviour under user error) may depend on the platform.
    ------------恢复内容结束------------

  • 相关阅读:
    pthread_key_t和pthread_key_create()详解
    oracle的时间
    spring加载bean报错:expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    MyBatis调用存储过程
    java的时间
    java的日期
    java中的多态
    笔记本设置wifi热点并抓包
    WiresShark使用说明
    HTTP协议概述
  • 原文地址:https://www.cnblogs.com/impw/p/13028521.html
Copyright © 2020-2023  润新知