Maybe this not need escaped "\b"

trinker

ggplot2orBust
#1
This code looks like this if I cat it to the console:

Code:
list(
    transcript_time_span = c(00:00 - 00:00),
    A = c(),
    B = c(),
    C = c() 
)
But prints a weird character for "\b" depending on the text editor. I want to get rid of the "\b" but still have it print appropriately to a file regardless of what codes is.

Code:
file <- "foo.txt"
codes <- LETTERS[1:3] 
[COLOR="gray"]#codes <- LETTERS[1:6]   #(codes could be this too)
#codes <- 1:9 or this    #(or this)[/COLOR]

cat(paste("list(\n",
    "   transcript_time_span = c(00:00 - 00:00),\n",
    paste0("    ", paste0("\b", paste(codes, 
        collapse = " = c(),\n    "), " = c()")), "\n)\n"),
file=file, append = TRUE)
 

Dason

Ambassador to the humans
#2
The best thing to do is get rid of the \b. This is easily accomplished by just using paste0 in place of the first paste.

Code:
cat(paste0("list(\n",
    "    transcript_time_span = c(00:00 - 00:00),\n",
    paste0("    ", paste0(paste(codes, 
        collapse = " = c(),\n    "), " = c()")), "\n)\n"),
    append = TRUE)
 

trinker

ggplot2orBust
#4
The output. May look boring to you but to me a thing of beauty:

Code:
[0]                                                                                30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[1]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[2]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[3]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[4]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[5]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[6]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
[7]0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                         


list(
    transcript_time_span = c(00:00 - 00:00),
    AA = c(),
    BB = c(),
    CC = c()
)