Message-ID: <2a9623fe-7e95-42ec-6f6b-ae0d41adae15@sapo.pt>
Date: 2018-12-18T10:55:54Z
From: Rui Barradas
Subject: Help with if else branching print out
In-Reply-To: <20181218122524.61065a8a@trisector>
Hello,
Yet another option is ?cat.
msg <- c("is not between 1 or 15",
"is *not* 6 - 9 inclusive, nor is it 12",
"falls within 6 - 9 inclusively, or is 12",
"is *not* 6 - 9 inclusive, nor is it 12",
"is not between 1 or 15")
nums <- as.numeric(readline("Please enter a number between 1 and 15: "))
i <- if(nums == 12) 2 else findInterval(nums, c(-Inf, 1, 6, 9, 15),
rightmost.closed = TRUE)
cat(nums, msg[i], "\n")
Hope this helps,
Rui Barradas
?s 09:25 de 18/12/2018, Ivan Krylov escreveu:
> On Tue, 18 Dec 2018 08:56:23 +0000
> Andrew <phaedrusv at gmail.com> wrote:
>
>> How do I:
>>
>> (a) reduce the gap between the reported number (i.e., 17, 9, 13) in
>> each of the lines? and
>>
>> (b) ensure that in the case of the second run using 9 as the input,
>> the print is not over two lines?
>
> Build a single string from your string parts. ?sprintf has already been
> mentioned; another option is ?paste.
>
> To prevent strings from being printed in quotes, use ?message.
>