<- 10:50
numbers numbers
[1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
[26] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
Classwork 2
Byeong-Hak Choe
September 18, 2024
October 5, 2024
numbers
containing the integers from 10 to 50.Answer:
[1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
[26] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
:
in R is used to generate a sequence of integers. In this case, 10:50
generates the integers from 10 to 50 and assigns them to the variable name numbers
.logical_vec
that checks whether the elements of the vector ages <- c(15, 22, 18, 24, 30)
are greater than or equal to 20.Answer:
>=
checks each element of the ages
vector to see if it’s greater than or equal to 20. The result is a logical vector of TRUE
or FALSE
values for each corresponding element.greeting
and display its value on the Console.Answer:
greeting
, and the value is displayed by simply typing the variable name, which prints its content to the Console.temp <- c(22, 28, 31, 25, 29)
.Answer:
max()
function gives the maximum value, and the min()
function gives the minimum value.char_vec <- c("1", "2", "3", "4")
into a numeric vector named num_vec
.Answer:
as.numeric()
function is used to convert the elements of char_vec
, which are characters, into numeric values. The resulting numeric vector is stored in num_vec
.first_names <- c("John", "Jane")
and last_names <- c("Doe", "Smith")
, to create a vector full_names
containing the full names using the str_c()
function for vectorized string operations.Answer:
[1] "John Doe" "Jane Smith"
str_c()
function from the one of the packages in tidyverse
is used to concatenate two vectors (first_names
and last_names
) element-wise. The sep = " "
argument ensures that a space is inserted between the first and last names.Welcome to our Classwork 2 Discussion Board! 👋
This space is designed for you to engage with your classmates about the material covered in Classwork 2.
Whether you are looking to delve deeper into the content, share insights, or have questions about the content, this is the perfect place for you.
If you have any specific questions for Byeong-Hak (@bcdanl) or peer classmate (@GitHub-Username) regarding the Classwork 2 materials or need clarification on any points, don’t hesitate to ask here.
Let’s collaborate and learn from each other!