
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 26504 Articles for Server Side Programming

2K+ Views
Most people get confused about levels and characters in R, especially the newbies. The difference is that levels specifically define the factor levels of a factor column and the characters are simple the character column that is not a factor or is not used as a factor but can be converted to a factor.ExampleConsider the below data frame −Live Demo> x1 x2 df1 df1Outputx1 x2 1 B B 2 B A 3 D D 4 D C 5 C A 6 D C 7 A D 8 D B 9 D C 10 B B 11 C B 12 D ... Read More

751 Views
If we want to use unicode characters in the title for a plot created with the help of ggplot2 package then the ggtitle function will be used combined with functions called expression and paste. Using the expression and paste functions, we can write unicode characters for the title of the plot. Check out the below examples to understand how it works.ExampleConsider the below data frame −Live Demo> x y df dfOutput x y 1 3.4501307 6.354644 2 2.1561511 5.349282 3 4.5018653 6.080046 4 2.5512959 5.957558 5 3.6818738 5.749713 ... Read More

364 Views
If a data frame contains missing value then visualising it in base R is not easily possible but we can make use of visdat package for this purpose. The vis_dat function of visdat package helps to visualize any data frame even if it contains missing values. For example, if a data frame df contains missing value then it can be visualized as vis_dat(df).Example1Consider the below data frame −Live Demo> x1 x2 x3 df1 df1Output x1 x2 x3 1 1 23 10 2 1 23 NA 3 NA NA 10 4 NA NA 10 5 1 24 NA 6 2 22 ... Read More

223 Views
To create a line for equal values of x and y in scatterplot, we can make use of segments function in base R but this can be done after creating the plot with the help of plot function. The segments function has four arguments, x0, y0, x1, and y1, we need to put the same value in x0 and y0 and the same value in x1 and y1 to draw the appropriate line as shown in the below examples.Example1Live Demo> x xOutput[1] -1.14191974 1.11554154 -0.01255755 1.18841175 1.11300329 -0.69925814 [7] -0.88000117 0.67830803 -0.91237446 -1.14223973ExampleLive Demo> y yOutput[1] -1.69229826 -0.70352587 0.38544874 0.14022473 ... Read More

781 Views
To plot the confidence interval of the regression model, we can use geom_ribbon function of ggplot2 package but by default it will have dark grey color. It can become transparent with the help of alpha argument inside the same function, the alpha argument can be adjusted as per our requirement but the most recommended value by me is 0.2.ExampleConsider the below data frame −Live Demo> x y df dfOutput x y 1 22.67102 29.37057 2 21.59415 29.54027 3 20.56817 28.27672 4 24.97228 31.38193 5 21.41651 31.86811 6 ... Read More

861 Views
In Data Analysis, we often required to extract a single value, a single row, or a single column for a specific analysis. For example, if data frame contains column defined as height and weight then we might want to use only height then it can be extracted, this could be a part of a list as well, therefore, extraction from list will be required. If we have a list of data frames then extraction of a column from one of the data frames in the list can be done by using double square brackets for accessing the data frame and ... Read More

1K+ Views
To convert a matrix into a color matrix, we can make use of image function. There are multiple ways for assigning the colors but the easiest one might be by defining the minimum and maximum value in the matrix. Also, we can do this by using the shades of a single color as shown in the example 3.Example1Live Demo> M1 M1Output [, 1] [, 2] [, 3] [, 4] [, 5] [1, ] 6 3 5 4 3 [2, ] 9 4 5 2 5 [3, ] 3 2 ... Read More

153 Views
To create a plot with tick marks but without axes lines, we first need to create the plot without axes and then add the tick marks. This can be done with the help of plot function and axis function in base R. The axis function will help us to decide where do we need the tick marks and the ticks.Example1> plot(1:10,axes=FALSE) > axis(1,c(1:10),col=NA,col.ticks=1)OutputExample2Live Demo> x xOutput[1] 5 2 1 2 1Example> plot(x,axes=FALSE) > axis(1,c(1:5),col=NA,col.ticks=1)Output

464 Views
If we have a list of data frames and the size of those data frames is same then we might want to combine the lists so that the data frames can be combined. This can be done by using mapply function along with cbind. For example, if we have two lists of data frames defined as List1 and List2 then we can combine them using the command −mapply(cbind, List1, List2, SIMPLIFY=FALSE).ExampleConsider the below data frame −Live Demo> x1 x2 df1 df1Output x1 x2 1 0.2378371 0.51433808 2 0.0638975 -1.66077353 3 0.3987209 0.68480587 ... Read More

3K+ Views
Generally, the space between two legend entries is not large enough and it becomes difficult to read the legend names if the names are long. In this case, we need to increase the margin between the legend entries/names but this would be required when the legends are horizontally aligned as vertical legends can be read as it is. For this purpose, we can use legend.text argument inside theme function of ggplot2 package.ExampleConsider the below data frame −Live Demo> x y df dfOutput x y 1 Male 501 2 Female 520Loading ggplot2 ... Read More