Change Y-Axis Title Text Size using ggplot2 in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:45:18

4K+ Views

By default, the text size of axes titles are small but if we want to increase that size so that people can easily recognize them then theme function can be used where we can use axis.title.y argument for Y-axis and axis.title.x argument for X-axis with element_text size to larger value.Check out the Example given below to understand how it can be done.ExampleFollowing snippet creates a sample data frame −Country

Find Row Median of Columns with Same Name in R Data Frame

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:41:24

268 Views

To find the row median of columns having same name in R data frame, we can follow the below steps −First of all, create a data frame with some columns having same name.Then, use tapply along with colnames and median function to find the row median of columns having same name.ExampleCreate the data frameLet’s create a data frame as shown below −df

Increase Axes Tick Width Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:39:50

5K+ Views

To increase the width of axes tick (both X-axis and Y-axis at the same time) using ggplot2 in R, we can use theme function with axis.ticks argument where we can set element_line argument size to a larger value.For Example, if we have a data frame called df that contains a single column X and we want to create histogram of X with wider axes ticks then we can use the command given below −ggplot(df,aes(X))+geom_histogram(bins=30)+theme(axis.ticks=element_line(size=2))ExampleFollowing snippet creates a sample data frame −x

Increase Width of Axes Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:35:27

7K+ Views

To increase the width of axes (both X-axis and Y-axis at the same time) using ggplot2 in R, we can use theme function with axis.line argument where we can set element_line argument to a larger value.Check out the Example given below to understand how it can be done.ExampleFollowing snippet creates a sample data frame −x

Convert First Letter to Capital in Data Frame Column using dplyr in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:33:59

679 Views

To convert first letter into capital in single column data frame in R, we can follow the below steps −First of all, create a data frame with string column.Then, use sub function along with mutate function of dplyr package to convert first letter into capital in string column.ExampleCreate the data frameLet’s create a data frame as shown below −Names

Change Border Style of a Plot Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:30:30

2K+ Views

To change the border style of a plot using ggplot2 in R, we can use theme function with panel.border argument where we can change the linetype for the plot border using element_rect. There are many linetypes and we can use them as desired.Check out the Example given below to understand how it can be done.ExampleFollowing snippet creates a sample data frame −x

Extract First N Values of All Elements of a List in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:30:22

6K+ Views

To extract the first n values of all elements of a list in R, we can follow the below steps −First of all, create a list.Then, use head function with sapply function to extract the first n values of all elements in the list.Example 1Create the listLet’s create a list as shown below −List1

Find Column Name with Value Greater Than Desired in R Data Frame

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:22:11

1K+ Views

To find the column name that contains value greater than a desired value in each row of an R data frame, we can use apply function along with lapply function.For Example, if we have a data frame called df and we want to extract column names for each row having values greater than 5 then we can use the command given below −lapply(apply(df,1, function(x) which(x5)),names)Example 1Following snippet creates a sample data frame −x1

Create ggplot2 Graph Without Axes Labels, Titles, and Ticks in R

Nizamuddin Siddiqui
Updated on 09-Nov-2021 05:15:31

192 Views

Sometimes we want to graphs that looks like graphs on a white paper having no axes labels, axes titles, and ticks, therefore, we can use theme_classic function of ggplot2 package.For Example, if we have a data frame called df that contains two columns say x and y then we can create the scatterplot between x and y using ggplot2 that looks like printed on white paper by using the below given command −ggplot(df,aes(x,y))+geom_point()+theme_classic(base_size=0)ExampleFollowing snippet creates a sample data frame −x

Convert Lex Program into Lexical Analyzer

Ginni
Updated on 08-Nov-2021 13:17:06

2K+ Views

SolutionConvert the pattern into NFA’sMake a Combined NFAConvert NFA to DFAA = ε − closure (0) = {0, 1, 3, 7}The transition on symbols a, b from state AFor State Aε − closure (Ta)                              ε − closure (Tb)= ε − closure ({2, 4, 7})                  = ε − closure ({8})= {2, 4, 7} = B                                = {8} = CFor State Bε − closure (7) ... Read More

Advertisements