R Programming Basics Guide
R Programming Basics Guide
1.List , define and summarize some basic data structures in R with suitable example.
2. How to create a data frame in R with the help of various data structures.
6. Create a data frame from the following 4 vectors and demonstrate the output:
emp_id = c (1:5)
emp_name = c("Rick", "Dan", "Michelle", "Ryan", "Gary")
start_date=c("2012-01-01", "2013-09-23", "2014-11-15", 03-27")
salary = c(60000, 45000, 75000, 84000, 20000)
ii. Extract the emp_name and salary columns from the above data frame.
iii. Extract the employee details whose salary is less than or equal to 60000.
7.List and explain various functions that allow users to handle data in R workspace with
appropriate examples.
8. Given the vector x=c(1,3,5,6,7,9,88,23,44,12,56) sort the vector in decreasing order and display
sum of elements <25 using suitable function.
Memory updated
No worries, Jaden! Let's break down the questions and I'll explain R programming step by step.
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 1/5
R
v <- c(1, 2, 3, 4)
Matrix: A two-dimensional array where each element has the same type. Example:
Data Frame: A table-like structure with rows and columns where each column can have different
types. Example:
Add a column:
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 2/5
R
Remove a column:
5. Functions Demonstration
v <- c(1, 2, 3)
v <- append(v, 4)
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 3/5
R
str(emp_df)
summary(emp_df)
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 4/5
R
ls()
rm(object_name)
getwd()
setwd("/path/to/directory")
Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 5/5