- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 2038 Articles for R Programming
1K+ Views
If we want to provide more information about the data, we have in columns of an R data frames then we might want to use prefixes. These prefixes help everyone to understand the data, for example, we can use data set name as a prefix, the analysis objective as a prefix, or something that is common among all the columns. To add a prefix to columns of an R data frame, we can use paste function to separate the prefix with the original column names.ExampleConsider the below data frame −Exampleset.seed(100) Rate
1K+ Views
Sometimes, we want to use some columns of an R data frame for analysis, therefore, it is better to get a list of all the columns that we need. In this way, we don’t have to worry about the column operations, if required because we will be having only necessary columns. To get the list of all columns except one or more columns can be done with the help of single square brackets.ExampleConsider the below data frame −set.seed(100) x1
191 Views
Scatterplot helps us to identify the linear relationship between two variables and it is the first step of determining a predictive model. Before using any predictive modeling technique we must draw a scatterplot between independent and dependent variables to check what kind of relationship exists between them. A scatterplot generally represented by circular points on the plot area but we can have different types of points such as square, rectangle, diamond, etc. In ggplot2, pch argument of geom_point can help us to create scatterplot with these types of points.ExampleConsider the below data frame −set.seed(123) x
5K+ Views
Comparison of columns of an R data frame can be done in many ways and one of the ways is having one or more columns of means. In this way, we can compare column of raw data with the column of means and also the column of means with another column of means. We can use apply function to create a new column with means of row values for each or some of the columns of an R data frame.ExampleConsider the below data framex1
2K+ Views
This error occurs when we do not pass the argument for independent variable as a data frame. The predict function will predict the value of the dependent variable for the provided values of the independent variable and we can also use the values of the independent variable using which the model is created.ExampleConsider the below data frame −set.seed(1) x
2K+ Views
Aesthetics is an essential part of a plot whether it is a scatterplot or any other plot. When we create a scatterplot with ggplot function of ggplot2 package, the border of the points is black if we fill the points with the sequence of a color but we can change these borders to any other color by using colour argument.ExampleConsider the below data frameRate
411 Views
Making comparisons is bit easier through horizontal bar graphs as compared to the vertical bar graphs in cases where the labels for the categories have large names. Because a large name for the labels of a vertical bar graph is likely to mix with the other labels and therefore, the reading of these labels become difficult for the viewer. To solve this problem, we can draw a bar graph and flip it with coord_flip() in ggplot2.ExampleConsider the below data frame −Size
2K+ Views
When we create a chart using plot function and add a legend to that chart, the output of the chart has the legend that is covered with borders. But this breaks the flow of the chart and the area covered by the order make the chart unattractive. Therefore, we can use bty="n" with the legend function and it will remove the border of the legend.ExampleCreating the chart with legend that has border −plot(x=1:10, y=10:1) legend(1, 2, "This is a scatterplot between x and y")OutputCreating the chart with legend which does not have a border −Exampleplot(x=1:10, y=10:1) legend(1, 2, "This is ... Read More
4K+ Views
There are many ways to initialize a data frame in R but initializing with matrix is the best among them because creating the data frame with matrix help us to avoid entering the wrong number of columns and the wrong number of rows. After initializing the matrix, we can simply use as.data.frame to convert the matrix into a data frame and that’s it.Examples Live Demodf1
279 Views
Reading transparent Venn Diagrams is a little difficult due to transparency in all areas, therefore, we should create Venn Diagrams that has different color in each of the area. This will help us to easily read the diagram and also the diagram will be more appealing to viewers. We can do this by using venn.diagram function of VennDiagram package.Installing and Loading VennDiagram package −Exampleinstall.packages(“VennDiagram”) library(VennDiagram)Creating the colored Venn Diagram (Note: The colored diagram will be saved in default folder for R in your system, mostly it is documents folder) −venn.diagram(list(x=1:10, y=7:12), fill=c("yellow", "black"), + filename = "Example1.tiff")Outputvenn.diagram(list(x=1:10, y=7:12, z=9:16), fill=c("yellow", ... Read More