What is the difference between string and character in R?

r, string

Solution

`is.string` is a function from the `xtable` package. In the details section of the help page it explicitly says "These functions are private functions used by print.xtable. They are not intended to be used elsewhere."

As such, I would avoid using those functions.

In `R` there is no `string` data type. Instead it is called `character` and you can use `is.character` to do the check you're describing.

Also, as I mentioned in my comment, avoid using important base functions as variable names. Specifically `str` is used to view the structure of an object.

Problem

I'm not pretty familiar with R, but anyhow I'm writing a R wrapper for a c library. I come across this problem. How do I decide if the input argument is a string? In details,should I write like this: ``` dyn.load("hello.so") do_process <- function(str) { if(!is.character(str)) stop("not a character or string"); result <- .Call("hello", as.character(str)) return result } ``` or this: ``` dyn.load("hello.so") do_process <- function(str) { if(!is.string(str)) stop("not a character or string"); result <- .Call("hello", as.string(str)) return result } ``` Thanks.

Original source