How to convert Logical Vector into Integer Vector in R?
[Pages:4]How to convert Logical Vector into Integer Vector in R?
R ? Convert Logical Vector into Integer Vector
To convert a given logical vector into integer vector in R, call as.integer() function and pass the logical vector as argument to this function. as.integer() returns a new vector with the logical values transformed into integer values.
During conversion, logical value of TRUE would be converted to integer value of 1, and logical value of FALSE would be converted to integer value of 0. NA (missing value) remains NA, because NA is allowed in integer vector.
Syntax
The syntax to use as.integer() to convert logical vector v1 to integer vector v2 is
v2 = as.integer(v1)
Examples
In the following program, we take a logical vector in v1 , and convert this to integer vector using as.integer(). We print the returned integer vector from as.integer(), and print the type of vector obtained programmatically using typeof() function.
example.R
v1 ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- i have a csv file and need to assign a data type to each
- h2o cheat sheet
- 1 given the following code fragment
- package toordinal cran
- homework two solution cse 355
- package stringr cran
- how to convert logical vector into integer vector in r
- flowgorithm documentation data types
- how to convert string to integer in r tutorial kart
- chapter 2 the basics of c programming
Related searches
- how to convert fractions into percentages
- how to convert list into numpy array
- how to convert tablespoon into ml
- how to convert binary into text
- how to convert watt hours into amps
- how to convert r markdown to pdf
- how to convert density into mass
- how to convert decimals into fractions steps
- how to convert into scientific notation
- how to convert binary into decimal
- how to convert a decimal into binary
- how to convert feet into square feet