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
Server Side Programming Articles - Page 1511 of 2646
1K+ Views
To create a sequence of time in minutes with date we can use seq function and define the date and time with as.POSIXct. For example, if we want to generate a sequence of time between 2 pm on tenth October 2020 to 4 pm on the same date then we can use the following code −seq(from=as.POSIXct("2020-10-10 14:00"), to=as.POSIXct("2020-10-10 16:00"), by="min")Example Live Demoseq(from=as.POSIXct("2020-01-01 00:01"), to=as.POSIXct("2020-01-01 01:00"), by="min")Output[1] "2020-01-01 00:01:00 IST" "2020-01-01 00:02:00 IST" [3] "2020-01-01 00:03:00 IST" "2020-01-01 00:04:00 IST" [5] "2020-01-01 00:05:00 IST" "2020-01-01 00:06:00 IST" [7] "2020-01-01 00:07:00 IST" "2020-01-01 00:08:00 IST" [9] "2020-01-01 00:09:00 IST" "2020-01-01 00:10:00 IST" [11] ... Read More
141 Views
When we have alternative missing values in two columns that makes the data frame look filled with values at alternate places in columns as well. In this case, we might want to remove those missing values so that the data frame becomes complete without any missing value. For this purpose we can use na.omit function with transform function as shown in the below examples.ExampleConsider the below data frame − Live Demox1
384 Views
To add a regression model line in a scatterplot created by using ggplot2, we need to use geom_smooth function to define the line for linear model. For example, if we have a data frame df that contains independent variable x and the dependent variable y then the regression line can be created by using the code −ggplot(df,aes(x,y))+geom_point()+geom_smooth(method="lm")ExampleConsider the below data frame − Live Demoset.seed(133) x
399 Views
In base R, the plot with different shape of points can be created by using pch argument inside the plot function but if we want to use any sign that is not designed for pch argument by default then we should pass that particular sign. For example, if we want to use cross sign then we can use letter x with pch as pch = "x".ExampleConsider the below vector and create the plot by displaying cross sign using letter x − Live Demox
2K+ Views
The plotting window size can be found by using dev.size function and we can pass in for inches and cm for centimeters. For example, if we create a plot then we can use dev.size("in") to find the plot size in inches and dev.size("cm") to find the size in centimeters.ExampleConsider the below vectors and create a point chart between those vectors − Live Demox
140 Views
We have to write a function that creates an array with elements repeating from the string till the limit is reached.Suppose there is a string ‘aba’ and a limit 5.e.g. string = "string" and limit = 8 will give new arrayconst arr = ["s", "t", "r", "i", "n", “g”, “s”, ”t”]ExampleLet’s write the code for this function −const string = 'Hello'; const limit = 15; const createStringArray = (string, limit) => { const arr = []; for(let i = 0; i < limit; i++){ const index = i % string.length; arr.push(string[index]); ... Read More
25K+ Views
If the row values are incorrectly recorded into columns then we might want to convert the columns into rows. Thus, to convert columns of an R data frame into rows we can use transpose function t. For example, if we have a data frame df with five columns and five rows then we can convert the columns of the df into rows by using as.data.frame(t(df)).Example Live Demoset.seed(4) x1
1K+ Views
In base R, the plot with different shape of points can be created by using pch argument inside the plot function. The list of pch values with shape is as written below −pch = 0 display square pch = 1 display circle pch = 2 display triangle point up pch = 3 display plus pch = 4 display cross pch = 5 display diamond pch = 6 display triangle point down pch = 7 display square cross pch = 8 display star pch = 9 display diamond plus pch = 10 display circle plus pch = 11 display triangles up ... Read More
371 Views
If we unique values in a vector in R and they are repeated then we can find the frequency of those unique values, this will help us to understand the distribution of the values in the vector. On the basis of that distribution analysis, we can proceed with the further analysis that could be used. This can be done with the help of rle function.Example Live Demox1
165 Views
Just like a list can have multiple elements, the elements of the list can have multiple sub-elements and the size of those elements may vary as well hence a list with single sub-elements is also possible. If we have such type of list then we can sort that list in decreasing order by using order function but we also need to unlist those elements.ExampleConsider the below list − Live Demox1