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
Programming Articles - Page 1139 of 3366
436 Views
To divide data frame rows by number of columns in R, we can follow the below steps −First of all, create a data frame.Then, use apply function to divide the data frame rows by number of columns.Create the data frameLet's create a data frame as shown below − Live Demox
153 Views
When we roll a die three times, the sample space contains two hundred and sixteen outcomes that is 216. If we want to generate the outcome of three throws of a die then expand.grid function can be used with rep and list function.Generating the outcome of three throws of a dieLet's create a data frame as shown below − Live Demoexpand.grid(rep(list(1:6),2))On executing, the above script generates the below output(this output will vary on your system due to randomization) −OutputVar1 Var2 1 1 1 2 2 1 3 3 1 4 4 1 5 5 1 6 6 1 7 1 2 8 2 2 9 3 2 10 4 2 11 5 2 12 6 2 13 1 3 14 2 3 15 3 3 16 4 3 17 5 3 18 6 3 19 1 4 20 2 4 21 3 4 22 4 4 23 5 4 24 6 4 25 1 5 26 2 5 27 3 5 28 4 5 29 5 5 30 6 5 31 1 6 32 2 6 33 3 6 34 4 6 35 5 6 36 6 6
206 Views
To find the proportion of categories based on another categorical column in R's data.table object, we can follow the below steps −First of all, create a data.table object.Finding the proportion based on categorical column.Create a data.table objectLoading data.table package and creating a data.table object with two categorical columns −library(data.table) Category1
220 Views
To divide the row values by row sum in R’s data.table object, we can follow the below steps −First of all, create a data.table object.Then, use apply function to divide the data.table object row values by row sum.Create the data.table objectLet’s create a data.table object as shown below −library(data.table) x
337 Views
To create density plot for categories filled with different colors, we can follow the below steps −Frist of all, create a data frame.Load ggplot2 package and creating the density plot for the categories.Create the density plot for the categories in the data frame by using fill function.Create the data frameLet's create a data frame as shown below − Live Demox
722 Views
To create density plot for categories, we can follow the below steps −Frist of all, create a data frame.Load ggplot2 package and creating the density plot for the whole data.Create the density plot for the categories in the data frame by using col function.Create the data frameLet's create a data frame as shown below − Live Demox
993 Views
If na.rm is set to TRUE using dplyr package then the output for statistical operations returns NaN. To avoid this, we need to exclude na.rm. Follow below steps to understand the difference between the tw −First of all, create a data frame.Summarise the data frame with na.rm set to TRUE if NA exists in the data frame.Summarise the data frame without setting na.rm to TRUE.Create the data frameLet's create a data frame as shown below − Live DemoGroup&li;-rep(c("First", "Second", "Third"), times=c(3, 10, 7)) Response&li;-rep(c(NA, 3, 4, 5, 7, 8), times=c(3, 2, 5, 2, 4, 4)) df&li;-data.frame(Group, Response) dfOn executing, the above ... Read More
437 Views
To label points in scatterplot created by using xyplot, we can follow the below steps −First of all, creating two numerical and one categorical vector.Loading lattice package and creating scatterplot.Creating the scatterplot with points labelled using categorical vector by panel.xyplot and ltext function.Creating the vectorsCreate three vectors, one categorical and two numerical − Live Demox
542 Views
To display categorical column name in facet grid, we can use the following steps −First of all, creating data frame.Loading ggplot2 package and creating a chart with facetsCreating the chart with facets and labeller function to display categorical column nameCreate the data frameLet's create a data frame as shown below − Live Demox
918 Views
To remove only first row from a data.table object we can follow the below steps −First of all, creating the data.table object.Subsetting the data frame with single square brackets by negation of 1Example1Create the data frameLet's create a data frame as shown below −library(data.table) x1