Getting invalid model formula in ExtractVars when using rpart function in R

The dataset can be downloaded from http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/ Getting the following error: Using the following code: Mind you I’ve changed the delimiters in the CSV file to commas. perhaps it’s not reading the data correctly. Forgive me, I’m new to R and not a very good programmer.

Categories R

Optimization of a function in R ( L-BFGS-B needs finite values of ‘fn’)

At some point in the optimization, your function is returning a value greater than .Machine$double.xmax (which is 1.797693e+308 on my machine). Since your function f1(…) is defined as sum(log(exp(…))), and since log(exp(z)) = z for any z, why not use this: Note that the vector of parameters (par) must be the first argument to f1.

Categories R

How do I install an R package from source?

If you have the file locally, then use install.packages() and set the repos=NULL: Where path_to_file would represent the full path and file name: On Windows it will look something like this: “C:\\RJSONIO_0.2-3.tar.gz”. On UNIX it will look like this: “/home/blah/RJSONIO_0.2-3.tar.gz”.

Categories R

How do I install an R package from source?

If you have the file locally, then use install.packages() and set the repos=NULL: Where path_to_file would represent the full path and file name: On Windows it will look something like this: “C:\\RJSONIO_0.2-3.tar.gz”. On UNIX it will look like this: “/home/blah/RJSONIO_0.2-3.tar.gz”.

Categories R

dplyr mutate with conditional values

Try this: giving: or this: giving: Note Suggest you get a better name for your data frame. myfile makes it seem as if it holds a file name. Above used this input: Update 1 Since originally posted dplyr has changed %.% to %>% so have modified answer accordingly. Update 2 dplyr now has case_when which provides another solution:

Function to calculate R2 (R-squared) in R

You need a little statistical knowledge to see this. R squared between two vectors is just the square of their correlation. So you can define you function as: Sandipan’s answer will return you exactly the same result (see the following proof), but as it stands it appears more readable (due to the evident $r.squared). Let’s … Read more

Categories R