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 1146 of 3363
493 Views
To merge two data frames of different length having same values in all columns but at different positions, we can follow the below steps −First of all, create two data frames.Then, merge them using merge function with all argument set to FALSE.Create the data frameLet's create a data frame as shown below − Live Demo> x y z df1 df1On executing, the above script generates the below output(this output will vary on your system due to randomization) −Output x y z 1 2 3 5 2 3 3 2 3 5 3 1 4 1 2 3 5 1 3 2 ... Read More
1K+ Views
To display ID column values in a scatterplot created with ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, create the scatterplot using ggplot2.After that, create the same plot with label argument inside aes and add the geom_text function.Create the data frameLet's create a data frame as shown below − Live Demo> ID x y df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) − ID x y 1 1 -0.6980655 0.4815529 2 2 1.0943027 0.2476090 ... Read More
876 Views
To remove rows from an R data frame based on frequency of values in grouping column, we can follow the below steps −First of all, create a data frame.Then, remove rows based on frequency of values in grouping column using filter and group_by function of dplyr package.Create the data frameLet's create a data frame as shown below − Live Demo> Group Rank df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) − Group Rank 1 IV 7 2 I 8 3 IV 2 4 I ... Read More
723 Views
To combine multiple R data frames that contains one common column, we can follow the below steps −First of all, create a number of data frames.Then, use join_all function from plyr package to combine the data frames.Create the data frameLet's create a data frame as shown below − Live Demo> x y1 df1 df1On executing, the above script generates the below output(this output will vary on your system due to randomization) − x y1 1 A 6 2 B 10 3 A 4 4 C 5 5 C 3 6 C 6 7 B 2 8 B 10 9 D ... Read More
1K+ Views
To remove row that contains maximum for each column in R data frame, we can follow the below steps −First of all, create a data frame.Then, remove the rows having maximum for each column using lapply and which.max function.Create the data frameLet's create a data frame as shown below − Live Demo> x1 x2 df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) − x1 x2 1 9 10 2 1 9 3 8 9 4 7 6 5 4 10 6 4 7 7 8 8 8 5 13 9 ... Read More
234 Views
To change the order of one column data frame and get the output in data frame format in R, we can follow the below steps −First of all, create a data frame.Then, use order function to change the order of column with drop argument set to FALSECreate the data frameLet's create a data frame as shown below − Live Demo> x df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) − x 1 -0.13734270 2 -1.02796577 3 1.40171778 4 -0.45367796 5 0.06634050 6 -1.27974403 ... Read More
649 Views
To set the position of legend of a ggplot2 graph to left-top side in R, we can follow the below steps −First of all, create a data frame.Then, create a plot using ggplot2 with legend.After that, add theme function to the ggplot2 graph to change the position of legend.Create the data frameLet's create a data frame as shown below − Live Demo> x y Grp df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) − x y Grp 1 1.534536456 ... Read More
195 Views
To divide the row values by row minimum 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 minimum.Create the data.table objectLet’s create a data.table object as shown below −> library(data.table) > x y z DT DTOn executing, the above script generates the below output(this output will vary on your system due to randomization) − x y z 1: 4 1 3 2: 4 3 1 3: 1 3 5 4: 1 5 5 5: 3 3 1 6: 3 ... Read More
136 Views
To divide matrix row values by row minimum in R, we can follow the below steps −First of all, create a matrix.Then, use apply function to divide the matrix row values by row minimum.Create the matrixLet’s create a matrix as shown below − Live Demo> M MOn executing, the above script generates the below output(this output will vary on your system due to randomization) − [,1] [,2] [,3] [1,] 16 1 18 [2,] 18 12 1 [3,] 12 19 19 [4,] 7 2 18 [5,] 10 14 16 [6,] 8 4 8 [7,] 15 14 4 [8,] 2 1 17 [9,] 11 12 8 [10,] 11 19 6 [11,] 8 2 7 [12,] 8 14 1 [13,] 5 19 18 [14,] 17 14 6 [15,] 13 12 18 [16,] 1 19 14 [17,] 9 19 17 [18,] 10 11 6 [19,] 3 2 2 [20,] 18 15 9 [21,] 11 18 11 [22,] 4 19 7 [23,] 3 9 19 [24,] 12 7 19 [25,] 5 5 2Divide the matrix row values by row minimumUsing apply function to divide the row values of M by row minimum − Live Demo> M M_new M_newOutput [,1] [,2] [,3] [1,] 16.000000 1.000000 18.000000 [2,] 18.000000 12.000000 1.000000 [3,] 1.000000 1.583333 1.583333 [4,] 3.500000 1.000000 9.000000 [5,] 1.000000 1.400000 1.600000 [6,] 2.000000 1.000000 2.000000 [7,] 3.750000 3.500000 1.000000 [8,] 2.000000 1.000000 17.000000 [9,] 1.375000 1.500000 1.000000 [10,] 1.833333 3.166667 1.000000 [11,] 4.000000 1.000000 3.500000 [12,] 8.000000 14.000000 1.000000 [13,] 1.000000 3.800000 3.600000 [14,] 2.833333 2.333333 1.000000 [15,] 1.083333 1.000000 1.500000 [16,] 1.000000 19.000000 14.000000 [17,] 1.000000 2.111111 1.888889 [18,] 1.666667 1.833333 1.000000 [19,] 1.500000 1.000000 1.000000 [20,] 2.000000 1.666667 1.000000 [21,] 1.000000 1.636364 1.000000 [22,] 1.000000 4.750000 1.750000 [23,] 1.000000 3.000000 6.333333 [24,] 1.714286 1.000000 2.714286 [25,] 2.500000 2.500000 1.000000
517 Views
To find the critical value of F for regression anova in R, we can follow the below steps −First of all, create a data frame.Then, create the regression model.After that, find the critical value of F statistic using qf function.Create the data frameLet's create a data frame as shown below − Live Demo> x y df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) − x y 1 5 5 2 0 9 3 1 3 4 3 5 5 2 5 6 2 4 7 3 6 8 4 6 ... Read More