Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

R Syntax Print


Sure! Printing in R is how you display output to the console. Here's how it works in simple language with examples:

Printing to the Console

To display something in R, you use the print() function or simply type the expression you want to see.

Example

# Using the print() function
print("Hello, world!")

# Without print(), just type the expression
"Hello, world!"

Example with Variables

You can also print the value of variables.

Example

x <- 10
y <- 20

# Using print() with variables
print(x)
print(y)

# Just type the variable name
x
y

Printing Results of Operations

You can print the results of calculations or operations.

Example

# Addition
print(3 + 5)

# Multiplication
print(4 * 6)

# Using variables
x <- 3
y <- 5
print(x + y)

Using cat() for Concatenation

Another way to print is using the cat() function, which concatenates and prints its arguments.

Example

cat("My name is", "John", "\n")

# Concatenating variables
name <- "Alice"
age <- 30
cat("Name:", name, ", Age:", age, "\n")

These are some simple examples of how to print in R. Printing is essential for debugging, displaying results, and communicating information in your code.


Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java