above function from the rmarkdown package works fine.
it takes rmd file and md file as input, converts rmd file content to md content and writes to md file.
Is there any function in rmarkdown package that takes rmd text as input and returns md text as output.
There is no function that do exactly like rmarkdown::render() that takes text. It operates on file with some YAML header. But that is easy enough to make a wrapper to write to text before converting with render()- did you try that ? Is something not working ?
Otherwise, Do you want to convert a full R Markdown document, or piece of it ?
knitr::knit()take text input and will convert to markdown by evaluating R code (but without pandoc conversion from Pandoc's Markdown to GFM)
pandoc::pandoc_convert() uses Pandoc only and take text input too. No R evaluation though. Useful if you need bare pandoc. Using to = "gfm" will convert to GFM content.