R Print Output
🖨️ R Print Output
🔹 1. Using print() Function
The most common way to display output.
Output:
✔ Automatically shows the value with index
🔹 2. Printing a Variable
Or simply type the variable name:
Output:
🔹 3. Using cat() Function
cat() is used to print clean output without quotes or index.
Output:
✔ Best for user-friendly messages
🔹 4. Printing Multiple Values
Using print()
Using cat()
Output:
🔹 5. New Line in Output
Output:
🔹 6. Printing Calculations
Output:
🔹 7. Printing Data Structures
Vector
Data Frame
🔹 8. Difference Between print() and cat()
| Feature | print() |
cat() |
|---|---|---|
| Shows index | Yes | No |
| Shows quotes | Yes | No |
| New line default | Yes | No |
| Best for | Debugging | User output |
🔹 Best Practice ✔
-
Use
print()for checking values -
Use
cat()for formatted messages
