is.character()
R語言中的函數用於檢查對象是否為字符串/字符形式。如果對象的任何元素是字符數據類型,它將返回 true。
用法: is.character(Object)
參數:
Object:它可以是數組、列表、向量等。
範例1:
# R Program to illustrate
# the use of is.character function
# Creating a vector of mixed datatype
x1 <- c("Hello", "Geeks", 100)
# Creating a vector of Numeric datatype
x2 <- c(10, 20, 30)
# Calling is.character() function
is.character(x1)
is.character(x2)
輸出:
[1] TRUE [1] FALSE
範例2:
# R Program to illustrate
# the use of is.character function
# Create the vectors with different length
vector1 <- c(1, 2, 3)
vector2 <- c("GFG", "Geeks", "Hello")
# taking this vector as input
result <- array(c(vector1, vector2), dim = c(3, 3, 2))
# Calling is.character() function
is.character(result)
輸出:
[1] TRUE
相關用法
- R語言 is.character()用法及代碼示例
- R語言 type.convert()用法及代碼示例
- R語言 is.complex()用法及代碼示例
- R語言 as.character()用法及代碼示例
- R語言 is.integer()用法及代碼示例
- R語言 is.numeric()用法及代碼示例
- R語言 mode()用法及代碼示例
- R語言 as.integer()用法及代碼示例
- R語言 typeof()用法及代碼示例
- R語言 is.matrix()用法及代碼示例
- R語言 is.list()用法及代碼示例
- R語言 exists()用法及代碼示例
- R語言 is.vector()用法及代碼示例
- R語言 is.call()用法及代碼示例
- R語言 is.table()用法及代碼示例
- R語言 is.expression()用法及代碼示例
- R語言 is.unsorted()用法及代碼示例
- R語言 sapply()用法及代碼示例
- R語言 data.matrix()用法及代碼示例
- R語言 with()用法及代碼示例
- R語言 sample()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi_biet大神的英文原創作品 Check if Object is of the Character Data type in R Programming – is.character() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。