Convert type of data object in R Programming - type.convert() Function Last Updated : 26 May, 2020 Comments Improve Suggest changes Like Article Like Report type.convert() function in R Language is used to compute the data type of a particular data object. It can convert data object to logical, integer, numeric, or factor. Syntax: type.convert(x) Parameter: x: It can be a vector matrix or an array Example 1: Apply type.convert to vector of numbers Python3 # R program to illustrate # type.convert to vector of numbers # create an example vector x1 <- c("1", "2", "3", "4", "5", "6", "7") # Apply type.convert function x1_convert <- type.convert(x1) # Class of converted data class(x1_convert) Output: [1] "integer" Here in the above code, we can see that before type.convert() function all the numbers are stored in it, but still its a character vector. And after the function it became "Integer". Example 2: Type conversion of a vector with both characters and integers. Python3 # R Program to illustrate # conversion of a vector with both characters and integers # create an example vector x1 <- c("1", "2", "3", "4", "5", "6", "7") # Create example data x2 <- c(x1, "AAA") # Class of example data class(x2) # Apply type.convert function x2_convert <- type.convert(x2) # Class of converted data class(x2_convert) Output: [1] "character" [1] "factor" Here, in the above code there were some characters and some integers after using type.convert() function. So, the output comes to be a factor. Comment More infoAdvertise with us Next Article Convert type of data object in R Programming - type.convert() Function akhilsharma870 Follow Improve Article Tags : R Language Similar Reads Convert an Object to a Table in R Programming - as.table() Function as.table() function in R Language is used to convert an object into a table. Syntax: as.table(x) Parameters: x: Object to be converted Example 1: Python3 1== # R Program to convert # an object to a table # Creating a vector vec = c(2, 4, 3, 1, 2, 3, 2, 1, 4, 2) # Calling as.table() Function as.table 1 min read Convert an Object to Data Frame in R Programming - as.data.frame() Function as.data.frame() function in R Programming Language is used to convert an object to data frame. These objects can be Vectors, Lists, Matrices, and Factors. Syntax: as.data.frame(object) Parameters: object: Vector, Matrix, factor, or data frameR - as.data.frame() Function ExampleExample 1: Basic exam 2 min read Convert a Vector into Factor in R Programming - as.factor() Function as.factor() function in R Programming Language is used to convert the passed object(usually Vector) into a Factor. Syntax: as.factor(object) Parameters: Object: Vector to be convertedas.factor() Function in R ExampleExample 1: Convert a Factor in RR # Creating a vector x<-c("female", "male", "ma 1 min read Convert an Object to a String in R Programming - toString() Function toString() function in R Language is used to convert an object into a single character string. Syntax: toString(x, width) Parameters: x: Object width: maximum string width Example 1: Python3 1== # R program to convert an object to string # Creating a vector x <- c("Geeks", "for 1 min read Get or Set the Type of an Object in R Programming - mode() Function mode() function in R Language is used to get or set the type or storage mode of an object. Syntax: mode(x) mode(x) <- value Here "value" is the desired mode or âstorage modeâ (type) of the object Parameters: x: R object Example 1: Python3 # R program to illustrate # mode function # Init 1 min read Convert an Object to List in R Programming - as.list() Function as.list() function in R Programming Language is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and dataframes. Syntax: as.list(object) Parameters: object: Vector, Matrix, factor, or data frame R - as.list() Function ExampleExample 1: Converting Vector to list 2 min read Convert an Object into a Vector in R Programming - as.vector() Function as.vector() function in R Language is used to convert an object into a vector. Syntax: as.vector(x) Parameters: x: Object to be converted Example 1: Python3 1== # R program to convert an object to vector # Creating an array x <- array(c(2, 3, 4, 7, 2, 5), c(3, 2)) x # Calling as.vector() Function 1 min read Convert an Integer to UTF8 in R Programming - intToUtf8() Function intToUtf8() function in R Language is used to convert an integer into UTF8 value. Syntax: intToUtf8(x, multiple) Parameters: x: Integer or integer vector multiple: Boolean value to convert into single or multiple strings Example 1: Python3 1== # R program to convert an integer to UTF8 # Calling the 1 min read Convert values of an Object to Logical Vector in R Programming - as.logical() Function as.logical() function in R Language is used to convert an object to a logical vector. Syntax: as.logical(x)Parameters: x: Numeric or character object R - as.logical() Function ExampleExample 1: Basic example of as.logical() Function in R Programming Language.R # R Program to convert # an object to l 1 min read Getting type of different data types in R Programming - typeof() Function typeof() function in R Language is used to return the types of data used as the arguments. Syntax: typeof(x) Parameters: x: specified data Example 1: Python3 # R program to illustrate # typeof function # Specifying "Biochemical oxygen demand" # data set x <- BOD x # Calling typeof() fun 1 min read Like