How to find cuberoot of a number in R?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

# How to find cuberoot of a number in R?

This recipe helps you find cuberoot of a number in R

0

## Recipe Objective

This recipe demonstrates how to calculate a cuberoot of a numeric variable

There is no built-in function to specifically calculate the cuberoot of a number. But there are two different ways in which you can do this.

1. Using the expontial arithmetic operator while defining a function;
2. Using nthroot() function in pracma package with n =3

## Step 1: Creating a numeric variable

We assign a number to a variable 'a' whose cuberoot needs to be calculated

``` a = -64 ```

## Step 2: Calculating Cuberoot in R

1) Defining a function using an exponential arithmetic operator:

We use the arithmetic operator " ^ " and defining a function 'cuberoot' to carry out this task. This defined function will deal with both positive and negative numeric variables.

``` # defining a function cuberoot in R that can accept an argument 'x' cuberoot = function(x){ if(x < 0) { - (-x)^(1/3)} else {x^(1/3)} } ​ # calling the function and giving a as an arguement cuberoot(a) ```
```-4
```

2) Using nthroot() function with n = 3

we use the built-in function nthroot() with n=3 to calculate the cuberoot of a numeric variable. nthroot() is a function present in "pracma" package.

Syntax: nthroot(x,n)

Where:

1. 'x' is a numeric vector
2. n' is a positive integer specifying the exponent (1/n)
``` # installing the pracma package first install.packages("pracma") ​ #calling and exceuting nthroot function on 'a' pracma::nthroot(a, 3) ```
```-4
```

#### Relevant Projects

##### Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

##### Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

##### Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

##### Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

##### Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

##### Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

##### Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

##### Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

##### German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

##### PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.