zoukankan      html  css  js  c++  java
  • 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.
    ------------恢复内容结束------------

  • 相关阅读:
    PHP实现微信小程序人脸识别刷脸登录功能
    thinkphp3.2.3中设置路由,优化url
    ThinkPHP URL 路由简介
    在 Linux 下搭建 Git 服务器
    图解 Android 广播机制 狼人:
    手机系统竞争背后的利益竞逐 狼人:
    你必须知道的Windows Phone 7开发 狼人:
    展望Android之前世今生 狼人:
    在美做开发多年,写给国内iPhone开发新手 狼人:
    NDK入门项目实战 狼人:
  • 原文地址:https://www.cnblogs.com/impw/p/13028521.html
Copyright © 2011-2022 走看看