100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Data_Mining_&_Statistical_Modeling_Week1_Introduction_to_R

Rating
-
Sold
-
Pages
10
Grade
A+
Uploaded on
05-06-2025
Written in
2024/2025

Replicate the textbook's code shown in Chapter 2 (2.3 Lab: Introduction to R). 2.3 Lab: Introduction to R In this lab, we will introduce some simple R commands to understand how R works. 2.3.1 Basic Commands 2.3.2 Graphics 2.3.3 Indexing Data 2.3.4 Loading Data

Show more Read less
Institution
Data Mining & Statistical Modeling
Course
Data Mining & Statistical Modeling









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Data Mining & Statistical Modeling
Course
Data Mining & Statistical Modeling

Document information

Uploaded on
June 5, 2025
Number of pages
10
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Intro_to_R
John Doe

2025-06-05

2.3 Lab: Introduction to R


In this lab, we will introduce some simple R commands to understand
how R works.
2.3.1 Basic Commands
# Creating a numeric vector with 4 elements
x <- c(1, 3, 2, 5)

# Printing the vector x
x

## [1] 1 3 2 5

# Updating x with a new set of values
x = c(1, 6, 2)

# Printing the updated x
x

## [1] 1 6 2

# Creating another numeric vector with 3 elements
y= c(1, 4, 3)


# Checking the number of elements in x
length(x)

## [1] 3

# Trying to find the length of y (this will give an error because y
doesn't exist yet)
length(y)

## [1] 3

# Adding x and y (will also give an error unless y is defined)
x + y

## [1] 2 10 5

, # Listing all current objects in the environment
ls()

## [1] "x" "y"

# Removing objects x and y from the environment
rm(x, y)

# Checking again to confirm they are removed
ls()

## character(0)

# Removing everything from the environment
rm(list = ls())

# Asking for help on the matrix function
?matrix

## starting httpd help server ... done

# Creating a 2x2 matrix using named arguments
x <- matrix(data = c(1, 2, 3, 4), nrow = 2, ncol = 2)
x

## [,1] [,2]
## [1,] 1 3
## [2,] 2 4

# Creating a matrix without naming the arguments (just positional)
x <- matrix(c(1, 2, 3, 4), 2, 2)

# Creating a matrix where values are filled by row instead of column
matrix(c(1, 2, 3, 4), 2, 2, byrow = TRUE)

## [,1] [,2]
## [1,] 1 2
## [2,] 3 4

# Taking square root of each element in x
sqrt(x)

## [,1] [,2]
## [1,] 1.000000 1.732051
## [2,] 1.414214 2.000000

# Squaring each element in x
x^2

## [,1] [,2]
## [1,] 1 9
## [2,] 4 16

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
datascience24 Self
View profile
Follow You need to be logged in order to follow users or courses
Sold
84
Member since
3 year
Number of followers
16
Documents
159
Last sold
1 month ago

Please message me using Send Message option for new assignment requests.

4.5

12 reviews

5
10
4
0
3
1
2
0
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions