
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

1K+ Views
A dummy variable is a type of variable that takes a value of 1 if the value for which the dummy variable is created exists in the data frame, otherwise it takes 0. Therefore, if we have a one binary variable in a data frame then there will be two dummy variables for the same. To create a dummy variable, we can use model.matrix function as shown in the below examples.Consider the below data frame −Example Live DemoTemp

8K+ Views
A binary variable is a type of variable that can take only two possible values like gender that has two categories male and female, citizenship of a country with two categories as yes and no, etc. If the binary variable is not in 0/1 format then it can be converted with the help of ifelse function. Check out the below examples to understand how it works.Consider the below data frame −Example Live DemoTemp

14K+ Views
To add an extra point to scatterplot using ggplot2, we can still use geom_point function. We just need to use aes function for quoting with new values for the variables, also we can change the color of this point using colour argument. The display of an extra point will help us to distinguish between a threshold/new value and remaining values.Consider the below data frame −Example Live Demox

3K+ Views
To extract words from a string vector, we can use word function of stringr package. For example, if we have a vector called x that contains 100 words then first 20 words can be extracted by using the command word(x,start=1,end=20,sep=fixed(" ")). If we want to start at any other word then starting value will be changed accordingly.Example Live Demox

156 Views
To find the rate of return for a vector values, we can use the formula for rate of return. For example, if we have a vector called x then the rate of return can be calculated by using the syntax diff(x)/x[-length(x)]. The output will be in decimal form and if we want to convert it to percentage then the output needs to be multiplied with 100, we can also input the same within the formula as (diff(x)/x[-length(x)])*100.Example Live Demox1

453 Views
Sometimes values in a string vector has an extra space at the end, this might happen while typing the values or due to some other manual errors. To remove spaces at the end in string vectors, we can use gsub function. For example, if we have a vector called x that contains string values with spaces at the end then the removal of values can be done by using the command gsub(" $","",x,perl=T)Example Live Demox1

1K+ Views
The integer64 vector contains vector values that represents signed integers with values that range from negative 9,223,372,036,854,775,808 to positive 9,223,372,036,854,775,807. To create an integer64 vector, we can use as.integer64 function of bit64 package. The difference between integer64 vector and others is that a large number of values can be stored in the vector.Examplelibrary(bit64) x1

697 Views
The pnorm function is used to find the probability for a normally distributed random variable. Probabilities such as less than mean, greater than mean, or probability between left- and right-hand side of the mean. If we want to use pnorm function on data frame columns then apply function can help us.Consider the below data frame −Example Live Demox1

8K+ Views
To manually define the breaks for a histogram using ggplot2, we can use breaks argument in the geom_histogram function. While creating the number of breaks we must be careful about the starting point and the difference between values for breaks. This will define the number of bars for histogram so it should be taken seriously and should be according to the distribution of the data.Consider the below data frame −Example Live Demox

2K+ Views
To fill NA values with next and previous values, we can use na.locf function of zoo package with fromLast = TRUE. This is the situation of a column as shown below −x 0 NA NA 1 1 NA 0 1The output after filling NA values with next and previous values will be −x 0 0 0 1 1 1 0 1Consider the below data frame −Example Live Demox1