R/stringToIntList.R

Defines functions stringToIntList

stringToIntList <- function(string) {
#-------------------------------
# convert one string in a list with the numbers in the string
# example: "111 222 333" -> c(111,222,333)
#-------------------------------
 
	limit = nchar(string)
	aux=""
	final=c()
	for(i in 1:limit)
	{
		if(substr(string,i,i) == " ")
		{
			if(nchar(aux) > 0)
			{
				final=c(final,as.integer(aux))
				aux=""
			}
		}
		else
		{
			aux = paste(aux,substr(string,i,i),sep="")
		}
	}
	return(final)
}

Try the RHRV package in your browser

Any scripts or data that you put into this service are public.

RHRV documentation built on Nov. 1, 2022, 1:05 a.m.