R Functions Return Value : <p>I am a new R user coming from the world of Java and SQL. I have been struggling the with the configuration or format of data that functions return in R. So far I have encountered three:</p>

<ul>
<li>Return actual data: for example, if you search through a data.frame, the return will be the rows that matched the search condition (a sub data.frame)</li>
<li>Return indices: for example, if you search through a data.frame, the result will be the indices of the rows that matched the search condition (1,3,20,22, ... etc)</li>
<li>Return a logical vector: for example, if you search through a data.frame, the return will a be a vector with 0s for the records that did not match and 1s for the records that matched (1,0,0,0,1,0,1,... etc). The size of the vector will be the exact number of records in the data.frame</li>
</ul>

<p>The inconsistency in the format of data returned is causing me a lot of confusion. Is there any way that I could convert between these formats or at least tell which format a function will return. </p>

<p>I tried looking into these resources but I could find a answer to my question
<a href="https://www.statmethods.net/management/subset.html" rel="nofollow noreferrer">https://www.statmethods.net/management/subset.html</a></p>

<p><a href="https://www.r-bloggers.com/5-ways-to-subset-a-data-frame-in-r/" rel="nofollow noreferrer">https://www.r-bloggers.com/5-ways-to-subset-a-data-frame-in-r/</a></p>

<p><a href="https://stat.ethz.ch/R-manual/R-devel/library/base/html/logical.html" rel="nofollow noreferrer">https://stat.ethz.ch/R-manual/R-devel/library/base/html/logical.html</a></p>

<p>Thank you</p>
