Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set NA values to TRUE for a Boolean column in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

Dealing with NA values is one of the boring and almost day to day task for an analyst and hence we need to replace it with the appropriate value. If in an R data frame, we have a Boolean column that represents TRUE and FALSE values, and we have only FALSE values then we might want to replace NA’s with TRUE. In this case, we can use single square bracket and is.na to set all NA’s to TRUE.Exampleset.seed(999) S.No.

Read More

How to create blue or red colored boxplots in R using ggplot2?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 296 Views

The default color of boxplot area in R using ggplot2 is white but we might want to change that color to something more attracting, for example blue or red. To do this purpose, we can use geom_boxplot function of ggplot2 package with fill argument by passing the color names.Consider the below data frame −Exampleset.seed(1321) v1

Read More

How to find the root mean square of a vector in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 890 Views

To find the root mean square of a vector we can find the mean of the squared values then take the square root of the resulting vector. This can be done in a single and very short line of code. For example, if we have a vector x and we want to find the root mean square of this vector then it can be done as sqrt(mean(x^2)).Examplex1

Read More

How to round correlation values in the correlation matrix to zero decimal places in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 5K+ Views

To find the correlation matrix, we simply need to use cor function with the data frame object name. For example, if we have a data frame named as df then the correlation matrix can be found by using cor(df). But the result will have too many decimal places to represent the correlation. If we want to avoid the values after decimal places, we can use round function.Consider the mtcars data in base R −Exampledata(mtcars) cor(mtcars)Output      mpg           cyl        disp        hp         drat       ...

Read More

How to create a list of an unordered combination of elements in a string vector in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 324 Views

An unordered combination of elements means that the combination of the values in a way that does not make any particular arrangement. For example, if we have three values one, two, and three then they can be arranged in the following way which is unordered −"one" "two" "three" "one" "two" "one" three" "two" "three" "one" "two" "three"Examplex

Read More

How to subtract one data frame from another in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 10K+ Views

If we have two data frames with same number of columns of same data type and equal number of rows then we might want to find the difference between the corresponding values of the data frames. To do this, we simply need to use minus sign. For example, if we have data-frames df1 and df2 then the subtraction can be found as df1-df2.Consider the below data frame −Examplex1

Read More

How to convert the repeated elements of strings in a vector to unique elements in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 263 Views

When we have repeated elements of strings and we want to use them as factor levels then it is okay but if we want to treat them individually then it is better to make each value a unique element. To do this, we can use make.unique function. For example, if we have a vector x that contains repeated string values then to make them unique, we can use make.unique(x).Examplex1

Read More

Manipulate two selects on page load with jQuery

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 550 Views

Let’s say the following is our first select −    John    David    Bob    Mike    Sam    Carol Following is our second select −    David    Mike    Carol We need to remove the options in the first select, which are similar to options in the second select. For this, use val(). Following is the complete code −Example              Document           John       David       Bob       Mike       Sam       Carol               David       Mike       Carol        $('#remaining_name > option').each(function (i, el) {       var value = $(el).val();       $('#all_present_name > option[value="' + value + '"]').remove();    }); OutputThe output is as follows −

Read More

How to print div content using jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 6K+ Views

Let’s say we have the following button −On click of the above button, call the function() with on() −$('#buttonId').on('click', function () {    displayTheData(); })The above function is using the html() to display the following div −    I am inside the div tag... ExampleFollowing is the complete code to print div content −            Document           I am inside the div tag...        I am not inside the div tag...            $('#buttonId').on('click', function () { ...

Read More

How to change a data frame with comma separated values in columns to multiple columns in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 998 Views

Mostly, we need to import the data from an outside source in R environment for analysis and these data can be recorded as comma separated values that represent rows. If we want to create the columns for the comma separated values then cSplit function of splitstackshape package can be used. In the below example, we have created a data frame with comma separated values then splitting those values as single value in each column.Consider the below data frame −Exampledf=data.frame(x=apply(matrix(rpois(200, 10), 20, 10), 1, paste, collapse=", ")) dfoutputx 1 8, 12, 7, 12, 10, 8, 11, 6, 8, 7 2 9, ...

Read More
Showing 26521–26530 of 61,297 articles
Advertisements