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 A 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 Like