🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
In this guide, we will show you how to run the R programs step-by-step in RStudio IDE.
Steps to Run R Program in RStudio
1. Open RStudio:
- Launch the RStudio application on your computer.
2. Start a New Script:
- Click on the File menu in the top-left corner.
- Hover over New File in the dropdown menu.
- Click R Script from the submenu. This will open a new script tab in the script editor pane.
3. Write or Paste Your R Program:
- In the script editor pane, type out your R code or paste it from another source.
4. Save the Script (optional, but recommended):
- Click on the File menu in the top-left corner.
- Select Save or Save As.
- Choose a location on your computer to save the file.
- Give the file a name, ensuring it has the .R extension, and click Save.
5. Run the Program:
6. View Output in the Console:
7. Interactive Input:
8. Close RStudio:
Example
# This program calculates the mean of a numeric vector
# Create a numeric vector
numbers <- c(10, 20, 30, 40, 50)
# Calculate the mean
mean_value <- mean(numbers)
# Print the mean value
cat("The mean of the numbers is:", mean_value, "\n")Steps to Run the Above Program in RStudio
1. Open RStudio:
Start the RStudio application.
2. Start a New Script:
Go to File > New File > R Script.
3. Write the Sample R Program:
In the script editor, paste or type out the R code provided above.
4. Save the Script:
Go to File > Save As. Navigate to your desired directory. Name the file something descriptive, like calculate_mean.R, and click Save.
5. Run the Program:
Click the Source button at the top-right of the script editor pane.
6. View Output in the Console:
Look in the console pane. You should see the output:
The mean of the numbers is: 30
7. Inspect Variables in the Environment Pane:
On the top-right pane, under the Environment tab, you'll notice an object numbers (a numeric vector) and an object mean_value (a numeric value of 30). This allows you to quickly inspect the variables you've created in your R session.
8. Close RStudio:
Save any unsaved work. Go to File and choose Quit Session or simply close the application window.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business

Comments
Post a Comment
Leave Comment