<?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: Potential bug in R Analytics App in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221072#M24205</link>
    <description>&lt;P&gt;Glad to hear it worked! I've added this question (and answer) to Splunkbase: &lt;A href="https://splunkbase.splunk.com/app/3339/#/details"&gt;https://splunkbase.splunk.com/app/3339/#/details&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 13:58:17 GMT</pubDate>
    <dc:creator>gwobben</dc:creator>
    <dc:date>2016-10-05T13:58:17Z</dc:date>
    <item>
      <title>Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221069#M24202</link>
      <description>&lt;P&gt;Hi guys at Itility, I attended your session at .conf 2016. I've been playing around with your R app and am seeing that frequently when using the runRdo custom command that I get inconsistent results coming back from R in Splunk. Example below.&lt;/P&gt;

&lt;P&gt;The search below occasionally comes back with the correct results and populates splunk with the test data frame. However, more often than not it comes back with a Null error. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup iris.csv | runRdo script="set.seed(1); my_iris = dataset[-5]; species = dataset$species; kmeans_iris = kmeans(my_iris,3); kmeans_table = table(kmeans_iris$cluster,species); test = as.data.frame(kmeans_table); return(test);"


#error results
message                                                      session         status
NA/NaN/Inf in foreign function call (arg 1) In call: do_one(nmeth)  0           400


#correct results
Var1    Freq    species
1      50   Iris Setosa
2      0    Iris Setosa
3      0    Iris Setosa
1      0    Iris Versicolor
2      2    Iris Versicolor
3      48   Iris Versicolor
1      0    Iris Virginica
2      36   Iris Virginica
3      14   Iris Virginica
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let  me know what you think.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 02:21:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221069#M24202</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2016-10-04T02:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221070#M24203</link>
      <description>&lt;P&gt;Thanks for using the R app! (and attending our presentation)&lt;/P&gt;

&lt;P&gt;There are a couple of things you need to take into account:&lt;BR /&gt;
 1. Splunk is not consistent in the order of the columns (even when using table or fields commands). This means that dataset[-5] will not give you a consistent column. We haven't found a workaround yet, however, you can use column names in R. &lt;BR /&gt;
 2. Splunk in not aware of any data types and will always send out strings (even when it's obvious that your data is numeric). Our app will try to parse the data as numeric but when it fails R will receive chars instead of numerics. It's most safe to cast data types in R explicitly.&lt;/P&gt;

&lt;P&gt;When debugging, you can use the parameter &lt;CODE&gt;getResults=false&lt;/CODE&gt; which will give you a link to the console output by R. When using the &lt;CODE&gt;str()&lt;/CODE&gt; command in R the console will show the data types.&lt;/P&gt;

&lt;P&gt;So back to your query. This example should work (works on my machine):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup iris.csv 
| runRdo script="
    # Fix the random seed
    set.seed(1);

    # Store the dataset in a variable
    my_iris = dataset;

    # Seperate the species column from the rest
    species = as.factor(my_iris$species);
    my_iris = my_iris[ , !(names(my_iris) %in% c('species'))];

    # Cast data types
    my_iris$petal_length = as.numeric(my_iris$petal_length);
    my_iris$sepal_length = as.numeric(my_iris$sepal_length);
    my_iris$petal_width = as.numeric(my_iris$petal_width);
    my_iris$sepal_width = as.numeric(my_iris$sepal_width);

    # Show summaries in the console, use getResults=false to see the link to the console
    str(species);
    str(my_iris);

    # Perform the kmeans
    kmeans_iris = kmeans(my_iris, 3);
    kmeans_table = table(kmeans_iris$cluster, species);

    # Return a dataframe
    return(as.data.frame(kmeans_table));" getResults=t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this fixes your issue! We'd love to hear how your using our app so stay in touch!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 09:34:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221070#M24203</guid>
      <dc:creator>gwobben</dc:creator>
      <dc:date>2016-10-04T09:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221071#M24204</link>
      <description>&lt;P&gt;Thank you this works perfectly! I can see now that the column order changes if I run the search multiple times. I will avoid using index references from now on and make sure to cast my data types as well.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 17:37:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221071#M24204</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2016-10-04T17:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221072#M24205</link>
      <description>&lt;P&gt;Glad to hear it worked! I've added this question (and answer) to Splunkbase: &lt;A href="https://splunkbase.splunk.com/app/3339/#/details"&gt;https://splunkbase.splunk.com/app/3339/#/details&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 13:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221072#M24205</guid>
      <dc:creator>gwobben</dc:creator>
      <dc:date>2016-10-05T13:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221073#M24206</link>
      <description>&lt;P&gt;Hi .. for me nothing is getting printed after clicking the run button in script editor &lt;BR /&gt;
not even error is coming ..&lt;BR /&gt;
is opencpu mandatory for this ? and can we isntall it in the same machine as splunk server ?&lt;/P&gt;

&lt;P&gt;please respond ASAP&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 22:37:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221073#M24206</guid>
      <dc:creator>splunk47</dc:creator>
      <dc:date>2016-12-16T22:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221074#M24207</link>
      <description>&lt;P&gt;Yes, OpenCPU is mandatory, and Yes, you can install it on the same machine. Good luck!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 10:02:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221074#M24207</guid>
      <dc:creator>gwobben</dc:creator>
      <dc:date>2016-12-19T10:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221075#M24208</link>
      <description>&lt;P&gt;public.opencpu.org would not work ?&lt;/P&gt;

&lt;P&gt;actually we dont have right to install opencpu as of now. &lt;BR /&gt;
so thought to use some public opencpu &lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 19:03:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221075#M24208</guid>
      <dc:creator>splunk47</dc:creator>
      <dc:date>2016-12-19T19:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221076#M24209</link>
      <description>&lt;P&gt;Sure, that should work. Just be absolutely sure you're willing to send your data and your algorithm to some unfamiliar host and be aware that you cannot use libraries that are not installed on the OpenCPU server that you're using.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 19:08:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221076#M24209</guid>
      <dc:creator>gwobben</dc:creator>
      <dc:date>2016-12-19T19:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221077#M24210</link>
      <description>&lt;P&gt;but nothing is coming when i am clicking the run button in splunk app &lt;BR /&gt;
R console tab is hidden only . at least some error should come &lt;BR /&gt;
ps i am using public.opencpu.org only&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 21:16:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221077#M24210</guid>
      <dc:creator>splunk47</dc:creator>
      <dc:date>2016-12-19T21:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221078#M24211</link>
      <description>&lt;P&gt;External search command 'runrpairs' returned error code 1. Script output = "error_message=ConnectionError at "/data/splunk_axpclp/lib/python2.7/site-packages/requests/adapters.py", line 375 : HTTPSConnectionPool(host='public.opencpu.org', port=443): Max retries exceeded with url: /ocpu/library/base/R/identity (Caused by : [Errno -2] Name or service not known) "&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:08:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221078#M24211</guid>
      <dc:creator>splunk47</dc:creator>
      <dc:date>2020-09-29T12:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug in R Analytics App</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221079#M24212</link>
      <description>&lt;P&gt;I've just tried public.opencpu.org on my own machine and it's working just fine.. Please make sure that your Splunk machine is able to connect to public.opencpu.org (no network issues / firewalls) and make sure that your configuration includes https as protocol (go to apps -&amp;gt; manage apps -&amp;gt; click on setup next to the R Analytics app -&amp;gt; fill out "&lt;A href="https://public.opencpu.org"&gt;https://public.opencpu.org&lt;/A&gt;" and click save).&lt;/P&gt;

&lt;P&gt;If this doesn't work, please share your setup.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 08:28:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Potential-bug-in-R-Analytics-App/m-p/221079#M24212</guid>
      <dc:creator>gwobben</dc:creator>
      <dc:date>2016-12-20T08:28:31Z</dc:date>
    </item>
  </channel>
</rss>

