0

I want to perform univariate assessment on a dataset. I came up with the code below:

library(dplyr)
data <- fnlDat_Train
data$response <- as.character(data$response)
data$Y <- sample(0:1,size=nrow(data),replace=TRUE)

univariate_list <- univariate(base = data,target = "Y",threshold = 0.95)
univariate_list$univar_table
univariate_list$num_var_name
univariate_list$char_var_name
univariate_list$sparse_var_name

I got an error message

Error in univariate(base = data, target = "Y", threshold = 0.95) : could not find function "univariate"

Here is my data structure

I need to do a scatterplot of a dataset that contains character, integer and numeric attributes.

Here is my code:

fdn <- read.table("final-data-train.csv",sep=",",header=TRUE)
pairs(~dtj+qh+sci+bw+is,data=fdn,row1attop=FALSE,subset=response,main="Fund Data")

Data Structure:

str(fnlDat_Train)
'data.frame':   30994 obs. of  19 variables:
 $ response: chr  "N" "N" "Y" "Y" ...
 $ id      : int  165931 241964 387089 433922 175120 353214 458159 512275 310008 91571 ...
 $ wc      : chr  "d" "b" "b" "b" ...
 $ zwp     : chr  "R" "S" "O" "Q" ...
 $ wi      : chr  "gnq" "gmz" "gmz" "gmz" ...
 $ dtj     : num  3.32 0 3.46 3.32 3.74 ...
 $ bnf     : chr  "J" "K" "J" "L" ...
 $ qh      : num  1.62 1.47 2.01 1.92 1.74 ...
 $ ent     : chr  "A" "A" "A" "A" ...
 $ sci     : num  1.36 1.42 1.43 1.41 1.36 ...
 $ ypz     : int  11 11 14 10 1 0 1 1 14 1 ...
 $ bw      : num  0.316 0.447 0.447 0.387 0.316 ...
 $ tdt     : chr  "kc" "sm" "zp" "sm" ...
 $ sb      : chr  "s2" "s2" "s2" "s2" ...
 $ ox      : chr  "bf" "fy" "ix" "bf" ...
 $ xt      : chr  "fcc" "ntb" "ntb" "ntb" ...
 $ np      : chr  "j" "j" "j" "k" ...
 $ ku      : chr  "y" "v" "u" "x" ...
 $ is      : num  0.241 3.762 2.5 2.477 4.171 ..

How can I fix this error?

DanY
  • 5,920
  • 1
  • 13
  • 33
  • `univariate()` is not a function in Base R nor the dplyr package. Which package has this function? – DanY May 11 '21 at 15:46
  • Hi DanY, I read through it, but it does not answer my question. I could not find the packages referenced in the link. Thank you. –  May 11 '21 at 16:34
  • When you install R on your machine, you get "base R". You can "extend" base R by installing and using packages. A package is a set of functions and possibly datasets. There are 2 steps in how most people use functions from packages: (1) get the package on your computer with `install.packages()` and (2) make the contents of the package available in your current R session with `library()`. Here, you are trying to use the function `univariate()` from some unknown package. You need to figure out which package contains the `univariate()` function and then do the two steps. – DanY May 11 '21 at 21:04
  • Thank you for the detailed explanation DanY. –  May 11 '21 at 23:15

1 Answers1

1

I believe what you're missing is library(scorecardModelUtils) at the top.

Leonardo Viotti
  • 476
  • 1
  • 5
  • 15
  • Hi Leonard, thank you for the help. There is no such package in r. Here is what I got: library(scorecardModelUtils) Error in library(scorecardModelUtils) : there is no package called ‘scorecardModelUtils –  May 11 '21 at 16:27
  • The issue seems to be that you need to install that first. You can do it by running `install.packages('scorecardModelUtils')` once. After that, it will be installed and you need `library()` to load it, but you don't have to include `install.packages()` in your script. – Leonardo Viotti May 11 '21 at 17:17
  • Thank you so much Leonardo, it worked after following the instruction you provided. –  May 11 '21 at 20:05
  • 1
    @Datanewbie if this answer has solved your question please consider [accepting it](https://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. Thank you! – Leonardo Viotti May 12 '21 at 12:17