Netsuite formula for randomizing numbers - formula

Is there a formula I can use in a saved search to randomize numbers in Netsuites. Like the excel formula =RANDBETWEEN?

NetSuite runs on an Oracle database so you can use the DBMS_RANDOM package for this
E.g ROUND(DBMS_RANDOM.VALUE(10, 20)) will give you a random integer number between 10 and 20, similar to Excel's =RANDBETWEEN(10,20)
You can read the official documentation here: https://docs.oracle.com/database/121/TTPLP/d_random.htm

Related

Create table with R Script in Power Query

I'm using R package "cluster" in Power BI to cluster customers from their historical transactions.
My data looks like this:
Using Run R-Script command in Power Query Editor, I have the following code:
library(cluster)
k.means.fit_log <- kmeans(dataset[2:4], 3)
output<-dataset
output$cluster <- k.means.fit_log$cluster
After this code is executed, I get an additional column with the number of the cluster and all looks good.
However, k.means.fit_log is a list with 9 rows, that contains the cluster centers, size, etc. so I'd like to be able to create another table or tables in Power BI with the contents of that object.
How can I achieve this?
Thanks in advance for your help!
If it is a list, and delimited, you can use the spilt function in Power Query. It would be good to share the R outputed table in your question

Comparison between two Data Sets using R Scripting / TERR in Spotfire

I want to compare the two data table columns ID using R-Script / TERR in spotfire. Due to some limitations in am not able to install the functions called "compare","SQLDf". I can use the functions called "duplicated". Can some one help me in creating the sample script with out using the above functions.
Please find the below images for the detailed requirements.
Two Data Table
Result Table
Thanks,
-Vidya
Let's say you have two vectors setA and setB. You can get the result by
# in A but not in B
setdiff(setA,setB)
# in B but not in A
setdiff(setB,setA)
# both in A and B
intersect(setA,setB)
If you just want to know the count use the length function. This may not be the exact answer you were looking for but using the above functions you can create any set you want. If you need help with a specific logic please update your question.

How to pass each row as an argument to R script from Tableau calculated field

I am trying to do sentiment analysis on a table that I have.
I want each row of string data to be passed to the R script, but the problem is that Tableau is accepting only aggregate data as params for:
SCRIPT_STR(
'output <- .arg1; output', [comments]
)
This gives me an error message:
# All fields must be aggregate or constant.
From the Tableau and R Integration documentation:
Given that the SCRIPT_*() functions work as table calculations, they
require aggregate measures or Tableau parameters to work properly.
Aggregate measures include MIN(), MAX(), ATTR(), SUM(), MEDIAN(), and
any table calculations or R measures. If you want to use a specific
non-aggregated dimension, it needs to be wrapped in an aggregate
function.
In your case you could do:
SCRIPT_STR(
'output <- .arg1; output', ATTR([comments])
)
ATTR() is a special Tableau aggregate that does the following:
IF MIN([Dimension]) = MAX([Dimension]) THEN
[Dimension] ELSE * (a special version of Null) END
It’s really useful when building visualizations and you’re not sure of the level of detail of data and what’s being sent
Note: It can be significantly slower than MIN() or MAX() in large data sets, so once you get confident your results are accurate then you can switch to one of the other functions for performance.
Try MIN([comments]) and make sure you have appropriate dimensions on your viz to partition the data fine enough to get a single comment for each combination of dimensions.

general to number in R

I have data in excel and after reading in R it reads as follows
as
lob2 lob3
1.86E+12 7.58E+12
I want it as
lob2 lob3
1857529190776.75 7587529190776.75
This difference causes me to have different results after doing my analysis later on
How is the data stored in Excel (does it think it is a number, a string, a date, etc.)?
How are you getting the data from Excel to R? If you save the data as a .csv file then read it into R, look at the intermediate file, Excel is known to abbreviate when saving and R would then see character strings instead of numbers. You need to find a way to tell excel to export the data in the correct format with the correct precision.
If you are using a package (there are more than 1) then look into the details of that package for how to grab the numbers correctly (you may need to make changes in Excel so that it knows they are numbers).
Lastly, what does the str function on your R object say? It could be that R is storing the proper numbers and only displaying the short version as mentioned in the comments. Or, it could be that R received strings that did not convert nicely to numbers and is storing them as characters or factors. The str function will let you see how your data is stored in R, and therefore how to convert or display it correctly.

Generation of binary data using Beta distribution in R

I am new user in R. In my work, I have to generate binary data(0 or 1) using beta distribution (rbeta command). I have to create a matrix of such data. In some of the columns I want to have more zeros than ones or ones more than zeros.
And this should be done taking shaping parameter 1 = shaping parameter 2 =0.5. I tried all combinations. But I am not able to do this. Please let me know the way to do the same. The hint I was provided was: Take probability(0) =some number and probability(1) = 1- probability(0). Then give these parameters to rbeta command. But I did not find such facility with rbeta command. Please let me knoe if there is any way.
Thanking you,
Kalyani

Resources