Write float arrays to a text file: Difference between revisions
Content added Content deleted
m (→{{header|R}}: not necessary to postprocess) |
|||
Line 1,313: | Line 1,313: | ||
=={{header|R}}== |
=={{header|R}}== |
||
<lang R>writexy <- function(file, x, y, xprecision=3, yprecision=3) |
<lang R>writexy <- function(file, x, y, xprecision=3, yprecision=3) { |
||
⚫ | |||
{ |
|||
⚫ | |||
#Format inputs as required, and join together |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
#Write to file. Note that this encloses the formatted number in quotes, |
|||
⚫ | |||
#... so we have to process the output |
|||
str <- readLines(file) |
|||
writeLines(gsub('"', '', str), file) |
|||
} |
} |
||
x <- c(1, 2, 3, 1e11) |
x <- c(1, 2, 3, 1e11) |
||
y <- sqrt(x) |
y <- sqrt(x) |
||
writexy( |
writexy("test.txt", x, y, yp=5)</lang> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |