Documentation for Eidos function format, which is a method of Eidos. Note that the R function is a stub, it does not do anything in R (except bring up this documentation). It will only do anything useful when used inside a slim_block function further nested in a slim_script function call, where it will be translated into valid SLiM code as part of a full SLiM script.

eidos_format(format, x)

Arguments

format

An object of type string or numeric. Must be of length 1 (a singleton). See details for description.

x

An object of type string or numeric. See details for description.

Value

An object of type string.

Details

Documentation for this function can be found in the official SLiM manual: page NA.

Returns a vector of formatted strings generated from x, based upon the formatting string format. The format parameter may be any string value, but must contain exactly one escape sequence beginning with the This escape sequence specifies how to format a single value from the vector x. The returned vector contains one string value for each element of x; each string value is identical to the string supplied in format, except with a formatted version of the corresponding value from x substituted in place of the escape sequence. The syntax for format is a subset of the standard C/C++ printf()-style format strings (available in many places online, such as http://en.cppreference.com/w/c/io/fprintf). The escape sequence used to format each value of x is composed of several elements: - A the beginning, initiating the escape sequence (if an actual desired, rather than an escape sequence, modify the style of formatting: • - : The value is left-justified with the field (as opposed to the default of right-justification). • + : The sign of the value is always prepended, even if the value is positive (as opposed to the default of appending the sign only if the value is negative). • space : The value is prepended by a space when a sign is not prepended. This is ignored if the + flag is present, since values are then always prepended by a sign. • # : An alternative format is used. For produced. For nonzero. For zeros follow. • 0 : Leading zeros are used to pad the field instead of spaces. This flag is ignored if the left-justification flag, -, is present. It is also ignored for integer values, if a precision is specified. - An optional minimum field width, specified as an integer value. Fields will be padded out to this minimum width. Padding will be done with space characters by default (or with zeros, if the 0 flag is used), on the left by default (or on the right, if the - flag is used). - An optional precision, given as an integer value preceded by a . character. If no integer value follows the . character, a precision of zero will be used. For integer values of x (formatted with extra zeros on the left if necessary), with a default precision of 1. For float values of x formatted with the minimum number of digits that will appear to the right of the decimal point (with extra zeros on the right if necessary), with a default precision of 6. - A format specifier. For integer values, this may be base-10 output; there is no difference between the two), or octal output), letters), or For float values, this may be form [−]ddd.ddd; there is no difference between the two), scientific notation (of the form [−]d.ddde±dd or [−]d.dddE±dd, respectively), or the formatting of depending upon the range of the value. Note that relative to the standard C/C++ printf()-style behavior, there are a few differences: (1) only a single escape sequence may be present in the format string, (2) the use of * to defer field width and precision values to a passed parameter is not supported, (3) only integer and float values of x are supported, (4) only the modifiers may be supplied, since Eidos does not support different sizes of the integer and float types. Note also that the Eidos conventions of emitting INF and NAN for infinities and Not-A-Number values respectively is not honored by this function; the strings generated for such 64 values are platform-dependent, following the implementation definition of the C++ compiler used to build Eidos, since format() calls through to snprintf() to assemble the final string values. For example, format("A number: a vector with three elements: "A number: -4.10" "A number: +15.38" "A number: +8.00". The precision of .2 results in two digits after the decimal point, the minimum field width of 7 results in padding of the values on the left (with spaces) to a minimum of seven characters, the flag + causes a sign to be shown on positive values as well as negative values, and the format specifier f leads to the float values of x being formatted in base-10 decimal. One string value is produced in the result vector for each value in the parameter x. These values could then be merged into a single string with paste(), for example, or printed with print() or cat().

See also

Other Eidos: Eidos, eidos_abs(), eidos_acos(), eidos_all(), eidos_any(), eidos_apply(), eidos_array(), eidos_asFloat(), eidos_asInteger(), eidos_asLogical(), eidos_asString(), eidos_asin(), eidos_assert(), eidos_atan2(), eidos_atan(), eidos_beep(), eidos_catn(), eidos_cat(), eidos_cbind(), eidos_ceil(), eidos_citation(), eidos_clock(), eidos_cmColors(), eidos_color2rgb(), eidos_colors(), eidos_cor(), eidos_cos(), eidos_cov(), eidos_createDirectory(), eidos_cumProduct(), eidos_cumSum(), eidos_c(), eidos_date(), eidos_dbeta(), eidos_debugIndent(), eidos_defineConstant(), eidos_defineGlobal(), eidos_deleteFile(), eidos_dexp(), eidos_dgamma(), eidos_diag(), eidos_dim(), eidos_dmvnorm(), eidos_dnorm(), eidos_drop(), eidos_elementType(), eidos_exists(), eidos_exp(), eidos_fileExists(), eidos_filesAtPath(), eidos_findInterval(), eidos_float(), eidos_floor(), eidos_flushFile(), eidos_functionSignature(), eidos_functionSource(), eidos_getSeed(), eidos_getwd(), eidos_heatColors(), eidos_hsv2rgb(), eidos_identical(), eidos_ifelse(), eidos_integerDiv(), eidos_integerMod(), eidos_integer(), eidos_isFinite(), eidos_isFloat(), eidos_isInfinite(), eidos_isInteger(), eidos_isLogical(), eidos_isNAN(), eidos_isNULL(), eidos_isObject(), eidos_isString(), eidos_length(), eidos_license(), eidos_log10(), eidos_log2(), eidos_logical(), eidos_log(), eidos_lowerTri(), eidos_ls(), eidos_match(), eidos_matrixMult(), eidos_matrix(), eidos_max(), eidos_mean(), eidos_min(), eidos_nchar(), eidos_ncol(), eidos_nrow(), eidos_object(), eidos_order(), eidos_paste0(), eidos_paste(), eidos_pmax(), eidos_pmin(), eidos_pnorm(), eidos_print(), eidos_product(), eidos_qnorm(), eidos_quantile(), eidos_rainbow(), eidos_range(), eidos_rank(), eidos_rbeta(), eidos_rbind(), eidos_rbinom(), eidos_rcauchy(), eidos_rdunif(), eidos_readCSV(), eidos_readFile(), eidos_repEach(), eidos_rep(), eidos_rev(), eidos_rexp(), eidos_rf(), eidos_rgamma(), eidos_rgb2color(), eidos_rgb2hsv(), eidos_rgeom(), eidos_rlnorm(), eidos_rmvnorm(), eidos_rm(), eidos_rnbinom(), eidos_rnorm(), eidos_round(), eidos_rpois(), eidos_runif(), eidos_rweibull(), eidos_sample(), eidos_sapply(), eidos_sd(), eidos_seqAlong(), eidos_seqLen(), eidos_seq(), eidos_setDifference(), eidos_setIntersection(), eidos_setSeed(), eidos_setSymmetricDifference(), eidos_setUnion(), eidos_setwd(), eidos_sin(), eidos_size(), eidos_sortBy(), eidos_sort(), eidos_source(), eidos_sqrt(), eidos_stop(), eidos_strcontains(), eidos_strfind(), eidos_string(), eidos_strprefix(), eidos_strsplit(), eidos_strsuffix(), eidos_str(), eidos_substr(), eidos_sumExact(), eidos_sum(), eidos_suppressWarnings(), eidos_sysinfo(), eidos_system(), eidos_tabulate(), eidos_tan(), eidos_tempdir(), eidos_terrainColors(), eidos_time(), eidos_trunc(), eidos_ttest(), eidos_type(), eidos_t(), eidos_unique(), eidos_upperTri(), eidos_usage(), eidos_var(), eidos_version(), eidos_whichMax(), eidos_whichMin(), eidos_which(), eidos_writeFile(), eidos_writeTempFile()

Author

Benjamin C Haller (bhaller@benhaller.com) and Philipp W Messer (messer@cornell.edu)