La función charmatch() en el lenguaje de programación R se usa para encontrar coincidencias entre dos argumentos.
Sintaxis: charmatch(x, tabla, nomatch = NA_integer_)
Parámetros:
- x: los valores a emparejar
- tabla: los valores a comparar
- nomatch: el valor entero que se devolverá en la posición no coincidente
r – ejemplo de función charmatch()
Ejemplo 1:
R
# R program to illustrate # charmatch function # Calling the charmatch() function charmatch("Geeks", c("Geeks", "forGeeks")) charmatch("for", c("Geeks", "forGeeks")) charmatch("forGeeks", c("Geeks", "forGeeks", "GeeksforGeeks")) charmatch("GeeksforGeeks", c("Geeks", "forGeeks", "GeeksforGeeks"))
Producción :
[1] 1 [1] 2 [1] 2 [1] 3
Ejemplo 2:
R
# R program to illustrate # charmatch function # Calling the charmatch() function charmatch("an", "sand") charmatch("and", "sand") charmatch("sand", "sand")
Producción:
[1] NA [1] NA [1] 1
Publicación traducida automáticamente
Artículo escrito por Kanchan_Ray y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA