R basename() Function

basename() Function in R

The basename() function in R is used to extract the last component (or the ‘base name’) of a file path. This function is helpful when retrieving the file name and effectively strips out all the directory parts of the path from a full path string. Syntax basename(path) Parameters path: It is a character vector containing … Read more

R substr() and substring() Functions

R substr() and substring() Functions

substr() function R substr() function is used to extract or replace substrings in a character vector. Syntax substr(str, start, stop) Parameters str:  It is a character string. start: If the characters of s were numbered, the first character would be returned. stop: The number of the last character to be returned. Example 1: Extracting a … Read more

R is.numeric() Function

R is.numeric() Function

The is.numeric() function in R is used to check if an object is of numeric type. Syntax is.numeric(obj) Parameters obj: It is an R Object to check whether it is numeric. Return value For a vector with numbers (either integer or double), it returns TRUE. For a character vector, it returns FALSE. For an integer … Read more

R aggregate() Function

R aggregate() Function

The aggregate() function in R returns a data frame with the results effectively summarizing data by groups. Syntax aggregate(x, by, FUN) Parameters x: It is an R object. by: It is a list of grouping items, each as long as the variables in the data frame x. FUN: It is a function to compute the summary statistics. … Read more

R fromJSON() Function

R fromJSON() Function

The fromJSON() function is a part of the jsonlite package, which is used for parsing and converting JSON data into R objects. It reads the content in JSON format and de-serializes it into logical, integers, real numbers, strings, arrays, and lists. Syntax fromJSON( json_str, file, method = “C”, unexpected.escape = “error”, simplify = TRUE ) … Read more

How to Convert Radians to Degrees in R

Convert Radians to Degrees in R

To convert radians to degrees in R, you can use the rad2deg() function. Syntax rad2deg(number) Parameters number: It accepts a number in radians. Example 1: Converting radians to degrees using REdaS To work with the rad2deg() function, you must install the REdaS package in your system. The next step will be to create an R file and import … Read more

How to Move Files Between Folders in R

Move Files Between Folders in R

Here are three ways to move files between folders in R: Using file.move() Using file.copy() Using file.rename() Method 1: Using file.move() To use the file.move() method, you must install the “filesstrings” package because of the file.move() method belongs to the “filesstrings” package. Let’s say we have a file called “Pro.R”, and it is inside the “env” … Read more

R sin() Function

sin() Function in R

The sin() function in R is used to calculate the sine of a given value or vector of values. For example, sin(0) returns 0 and sin(pi/2) returns 1. Syntax sin(number) Parameters number: It accepts a number representing an angle in radians as a parameter. Return value It returns the sine of a number (in radians) … Read more

R log2() Function

R log2() Function

The log2() function is used to calculate the base-2 logarithm of a number or a vector of numbers. Syntax log2(number) Parameters number: It is a number whose logarithm base 2 must be calculated. Return value It returns the logarithm of a number to the base 2. If the number is zero, then this function outputs … Read more