Blog
How to Solve R Error: Could not find function “%>%”
The pipe operator, %>%, is a special function available under the magrittr package that allows you to pass the result of one function/argument to the other one in sequence. To use the pipe operator, you need to install and load the magrittr package....
How to Remove Outliers from Boxplot using ggplot2 in R
This tutorial will go through how to remove outliers from a boxplot using ggplot2 in R with the help of code examples. Table of contentsExampleRemove Outlier Using outlier.shape=NASummary Example In the following example, we are going to use the iris dataset to create...
How to Place Two Plots Side by Side using ggplot2 and cowplot in R
The easiest way to place two plots side by side using ggplot2 is to install gridExtra and then use the grid.arrange() function. For example, install.packages("gridExtra") grid.arrange(plot1, plot2, ncol=2) This tutorial will go through how to place two plots side by...
How to Get an Absolute Value in Rust
We can calculate the absolute value of a number using the abs() method. We have to specify the numeric type before we call the abs method, for example, if we want a 32-bit signed integer we need to put i32 after the number. This tutorial will go through how to...
How to Solve Python AttributeError: ‘datetime.datetime’ object has no attribute ‘timestamp’
The timestamp method was added in Python 3.3. If you try to call the timestamp method with Python version 3.2 or earlier, you will raise the AttributeError: 'datetime.datetime' object has no attribute 'timestamp'. You can solve this error by upgrading to the latest...
How to Solve Python AttributeError: ‘str’ object has no attribute ‘reverse’
This error occurs when you try to reverse a string by calling reverse() directly on the string object. The reverse() method belongs to the List data type, not String. You can solve this error by using the subscript operator, for example, reversed_str = a_str[::-1]...
How to Rotate and Space Axis Labels in ggplot2 with R
You can rotate the axis labels by using angle parameter of the element_text() function when modifying the theme of your plot, for example: theme(axis.text.x = element_text(angle = 90, vjust = 0.5) We can use vjust and hjust in element_text() to add horizontal and...
How to Solve Python AttributeError: ‘str’ object has no attribute ‘sort’
This error occurs when you try to sort a string by calling sort() directly on the string object. You can solve this error by using the built-in sorted() method, which returns a list, and then you can join the list into a string using the join() method. For example,...
How to Solve Python AttributeError: module ‘datetime’ has no attribute ‘combine’
This error occurs when you import the datetime module and try to call the combine() method on the imported module. You can solve this error by importing the datetime class using from datetime import datetime or accessing the class method using...
How to Order Bars in ggplot2 Bar Graph with R
This R tutorial will go through how to order bars in a ggplot2 bar chart with code examples. Table of contentsExampleSolution #1: Manually Order BarsSolution #2: Sort Bars in Descending OrderSolution #3: Sort Bars in Ascending OrderSummary Example Consider the...
Suf is a senior advisor in data science with deep expertise in Natural Language Processing, Complex Networks, and Anomaly Detection. Formerly a postdoctoral research fellow, he applied advanced physics techniques to tackle real-world, data-heavy industry challenges. Before that, he was a particle physicist at the ATLAS Experiment of the Large Hadron Collider. Now, he’s focused on bringing more fun and curiosity to the world of science and research online.