<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240634#M188836</link>
    <description>&lt;P&gt;I made a very simple example that works:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;|stats count by source 
|r "simpleFunction &amp;lt;-function(class){
                          out&amp;lt;-sum(class)
                          return(out)}
output &amp;lt;- simpleFunction(input$count)"&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I just saw your longer example and I'll look at it.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Oct 2015 21:14:20 GMT</pubDate>
    <dc:creator>walkerhound</dc:creator>
    <dc:date>2015-10-01T21:14:20Z</dc:date>
    <item>
      <title>Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240626#M188828</link>
      <description>&lt;P&gt;I am using the R Project with splunk. &lt;/P&gt;

&lt;P&gt;My query goes something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index= abcd host= pqrs NOT host=aacd NOT host =  ppwqrs | fields DUR, TYPE | timechart limit=0 span=10m count, avg(DUR)  by  TYPE | r "   data= input 
avg.calls.day &amp;lt;- function(calls){
total.calls &amp;lt;- sum(calls)
out &amp;lt;- total.calls/ndays
return(out)
}
output =  avg.calls.day"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;But it keeps throwing me this error  &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;PRE&gt;&lt;CODE&gt;command="r", cannot coerce class ""function"" to a data.frame. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/676i1FF1EE87ED325D48/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Why am i getting this error and how do I resolve it?  &lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 21:40:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240626#M188828</guid>
      <dc:creator>m_vivek</dc:creator>
      <dc:date>2015-09-25T21:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240627#M188829</link>
      <description>&lt;P&gt;I have to admit that I don't know much R, but with this &lt;A href="http://stackoverflow.com/questions/22712409/putting-functions-into-a-data-frame"&gt;StackOverflow post&lt;/A&gt; it seems like this error is something to do with how you're returning  a function as a value?&lt;/P&gt;</description>
      <pubDate>Sat, 26 Sep 2015 02:49:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240627#M188829</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-09-26T02:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240628#M188830</link>
      <description>&lt;P&gt;Thanks @acharlieh. While my r code is running just fine in R studio, I am facing issues when I am running it in Splunk with the R Project.  My goal is automation,- to run my Rscript in Splunk using the R Project. &lt;/P&gt;</description>
      <pubDate>Sun, 27 Sep 2015 18:15:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240628#M188830</guid>
      <dc:creator>m_vivek</dc:creator>
      <dc:date>2015-09-27T18:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240629#M188831</link>
      <description>&lt;P&gt;Trying doing your average without going through a function and see how it goes.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 08:07:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240629#M188831</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2015-09-28T08:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240630#M188832</link>
      <description>&lt;P&gt;Are you able to run any other r-scripts through the command?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 02:05:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240630#M188832</guid>
      <dc:creator>muebel</dc:creator>
      <dc:date>2015-09-30T02:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240631#M188833</link>
      <description>&lt;P&gt;Hi @muebel , the r -script until this line is running just fine.   &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 22:17:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240631#M188833</guid>
      <dc:creator>m_vivek</dc:creator>
      <dc:date>2015-09-30T22:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240632#M188834</link>
      <description>&lt;P&gt;I don't see where you are applying the function to your input.&lt;/P&gt;

&lt;P&gt;I would say, define your function and then &lt;/P&gt;

&lt;P&gt;output =  avg.calls.day(input)&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 13:04:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240632#M188834</guid>
      <dc:creator>walkerhound</dc:creator>
      <dc:date>2015-10-01T13:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240633#M188835</link>
      <description>&lt;P&gt;Hi @DavidHourani,  it works if i don't use it as a function. but i really need it to be a function as I use it in all the other calculations. &lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 19:03:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240633#M188835</guid>
      <dc:creator>m_vivek</dc:creator>
      <dc:date>2015-10-01T19:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240634#M188836</link>
      <description>&lt;P&gt;I made a very simple example that works:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;|stats count by source 
|r "simpleFunction &amp;lt;-function(class){
                          out&amp;lt;-sum(class)
                          return(out)}
output &amp;lt;- simpleFunction(input$count)"&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I just saw your longer example and I'll look at it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 21:14:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240634#M188836</guid>
      <dc:creator>walkerhound</dc:creator>
      <dc:date>2015-10-01T21:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why is R in Splunk giving me a ' trying to coerce a function to a dataframe' error?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240635#M188837</link>
      <description>&lt;P&gt;I am probably missing something but I still don't see where you are using "input".  The variable "input" is what r brings in from the Splunk search before the r script.  and then "output" is what is returned back to the search.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 21:20:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-R-in-Splunk-giving-me-a-trying-to-coerce-a-function-to-a/m-p/240635#M188837</guid>
      <dc:creator>walkerhound</dc:creator>
      <dc:date>2015-10-01T21:20:30Z</dc:date>
    </item>
  </channel>
</rss>

