
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2038 Articles for R Programming

980 Views
Suppose we have a data frame called df that contains two columns say X and Y then we can create a group column based on X and Y by converting df into a data.table object and creating list of values in X and Y with list function.Check out the below Examples to understand how it can be done.Example 1Following snippet creates a sample data frame −x1

836 Views
If we want to multiply two matrices if they contain missing values then we first need to convert the missing values to zeros and then the multiplication can be easily done. If we do not do so then the Output of the multiplication will have NAs at all positions.Check out the Examples given below to understand the correct of multiplication if NAs are present in the matrices.Example 1Following snippet creates a sample matrix −M1

352 Views
To hide outliers in base R boxplot, we can use range argument inside boxplot function but we will have to play with range argument. The range argument can take many values therefore, we would need to find the correct one that removes all the outliers. To understand how it works check out the Example given below −ExampleTo hide outliners in base R boxplot, use the following snippet −x

1K+ Views
To create darker gridlines in theme_bw for a ggplot2 graph, we can use theme function, where we can use major and minor gridlines element line to black color with the help of panel.grid.major and panel.grid.minor argument as shown in the below Example.We can use any other color but black is the most preferred one as it matches with the border color.ExampleFollowing snippet creates a sample data frame −x

2K+ Views
To check if a matrix has any missing value in R, we can use any function along with is.na function.For Example, if we have a matrix called M then we can use the below command to check whether M contains any missing value or not −any(is.na(M))Example 1Following snippet creates a sample matrix −M1

2K+ Views
To remove line numbers from data.table object in R, we can set row.names to FALSE and print the data.table object.For Example, if we have a data.table object called DT then we can remove line numbers from DT by using the command given below −print(DT,row.names=FALSE)Example 1To load data.table object and create an object use the following snippet to create a data frame −library(data.table) x1

1K+ Views
To create stacked bar plot for one categorical variable in an R data frame, we can use ggplot function and geom_bar function of ggplot2 and provide 1 as the X variable inside aes.For Example, if we have a data frame called df that contains a one categorical column say C and one numerical column Num then we can create the stacked bar plot by using the below command −ggplot(df,aes(1,Num,fill=C))+geom_bar(stat="identity")ExampleFollowing snippet creates a sample data frame −x

188 Views
To find the value in an R data frame column that exist n times, we first need to tabulate the column with factor then extracting the levels of the column after that reading them with as.numeric.Check out the Examples given below to understand how it can be done.Example 1Following snippet creates a sample data frame −x

7K+ Views
To display numbers with decimal in R data frame column, we can use format function with round function and nsmall argument.For Example, if we have a data frame called df that contains an integer column say X then we can display numbers in X with 2 decimal places by using the below command −df$X