Someone can correct me on this, but I think that you are passing Primus and Name as objects to the function and it is looking in the .GlobalEnv for those objects and is not finding them, therefore your function is failing to carry out most of your instructions (and is returning nothing). I have edited your function a bit.
Instead try this...
namezz <- function( pattern = " ", data , column= "Name" ){
library(stringr)
strings <- data[ , column ] ##data$column is a character vector
found = str_detect( strings , pattern )
yez = rownames( data[ which( found==TRUE ) , ] )
hhh = as.numeric( yez ) + 1
return( hhh )
}
Then you must use the function like so:
namezz( "Primus" , data = data ) #In this case the default for column is "Name" as you want
The problem with passing data = data is explained very nicely here. An excerpt from that post (where they refer to testparams you would refer to data)...
"One of the most important things to know about the evaluation of
arguments to a function is
that supplied arguments and default arguments are treated differently.
The supplied arguments
to a function are evaluated in the evaluation frame of the calling
function. The default arguments
to a function are evaluated in the evaluation frame of the function."
the parameter testparams, when no matching argument is passed, is given
the default value which is the value of the variable testparams
looked-up not in the environment where foo is defined, and not in
the environment where foo is called, but rather in the local environment
created when the function is called and where parameters are mapped to
values -- and in this environment, testparams is a parameter, which is
already being under evaluation, hence the recursive lookup error.