Answers for "create vector in r"

R
1

create vector in r

#Use the c() function to store data in a vector. 
c(2.5, 48.5, 101.5)

#To create a vector of integers using the c() function, 
#you must place the letter "L" directly after each number.
c(1L, 5L, 15L)

#To create a vector containing characters aka strings 
c("Sara" , "Lisa" , "Anna")

#To create a vector containing logicals aka logicals
c(TRUE, FALSE, TRUE)
Posted by: Guest on September-21-2021
3

r create a vector

# Basic syntax:
c(11, 23, 42) # Vector of numerics
c(TRUE, FALSE, TRUE) # Vector of booleans/logicals
c("aa", "bb", "cc") # Vector of strings

# Note, in R, list and vectors (aka atomic vectors) are both 
#	one-dimensional objects, but lists can contain mixed type data 
#	whereas vectors can only contain one type of data
# Note, to make a list, use: list(11, 23, 42)
Posted by: Guest on October-10-2020

Browse Popular Code Answers by Language