R console output only shows most recent command in if condition

0 votes
In RStudio, if I execute this code:

"1 + 1 is: percent d," sprintf(1+1),
"2 + 2 is: percent d," sprintf(2+2)

If (1), then sprintf("1 + 1 is: percent d", 1+1) and sprintf("2 + 2 is: percent d," 2+2) are appropriate.
This is what I receive:

"1 + 1 is: percent d," sprintf(1+1),
[1] sprintf("1 + 1 is: 2," "2 + 2 is: percent d", 2+2)
[1] "2 + 2 is: 4" > \s> if (1+sprintf "1 + 1 is: percent d", 1+1)
+ sprintf("%D is: 2 + 2 is:", 2+2)
+ } [1] "2 Plus 2 is: 4"
Why doesn't the 1+1 line, which is the initial print statement in the if(1) condition, print to the console as well, I wonder? Every time I have a "if" condition with numerous output lines that I want to print or plot, it seems that only the final one displays. How do I repair this?
Jul 5 in Data Science by avinash
• 1,840 points
7 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Data Science

0 votes
0 answers

R command for setting working directory to source file location in Rstudio

I am working out some tutorials in ...READ MORE

Jul 20 in Data Science by avinash
• 1,840 points
5 views
0 votes
0 answers

Introduction to Statistical Learning with Applications in R Figure Codes

I recently bought the following book: An Introduction ...READ MORE

Jun 1 in Data Science by avinash
• 1,840 points
31 views
0 votes
1 answer

Difference between the == and %in% operators in R

percent in percent "returns a vector of ...READ MORE

answered Jun 20 in Data Science by Sohail
• 2,960 points
20 views
0 votes
1 answer

Difference between the == and %in% operators in R

According to help('percent in percent'), percent in ...READ MORE

answered Jun 23 in Data Science by Sohail
• 2,960 points
14 views
0 votes
1 answer

How to make loop for one-at-a time logistic regression in R?

You're probably looking for something similar to ...READ MORE

answered Jun 20 in Data Science by Sohail
• 2,960 points
56 views
0 votes
1 answer

do-while loop in R

Unlike for and while loops, which test the loop condition at ...READ MORE

answered Jun 1 in Data Science by Sohail
• 2,960 points
32 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
434 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
478 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
4,345 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
502 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP