Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

R language ggplot2 how to put axes to the right, change drawing boundaries and sort data groups

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about R language ggplot2 how to put the coordinate axis to the right, change the drawing boundary and data grouping sorting, the editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

Ggplot2 draws the label of the Y axis to the right

The normal axes are located on the left and bottom, so if you want to change it to the top or right, you can use the following code

Normal

Library (ggplot2)

Df df library (dplyr)

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

Filter, lag

The following objects are masked from 'package:base':

Intersect, setdiff, setequal, union

> df% >%

+ group_by (group)% >%

+ arrange (group,value)

# A tibble: 6 x 2

# Groups: group [2]

Group value

1 A 4

2 A 5

3 A 7

4 B 2

5 B 4

6 B 6

Collation of GO comment results

The result of GO comments is usually two columns, the first column is the GO number, and the second column is a number of gene names, separated by commas. It's like the following.

GO0001 gene1,gene2

GO0002 gene5,gene3,gene4

GO0003 gene3,gene10

Sometimes we need to sort it out into the form of a single gene corresponding to a GO number.

That's it.

V1 V2

1 GO0001 gene1

2 GO0001 gene2

3 GO0002 gene5

4 GO0002 gene3

5 GO0002 gene4

6 GO0003 gene3

7 GO0003 gene10

My initial solution was to write a simple python script. Yesterday, I saw the R language code given by someone in a WeChat group. It's easy to use. Record it here.

# install.packages ("tidyr")

Library (tidyr)

Df%

The above is how the R language ggplot2 puts the coordinate axis to the right, changes the drawing boundary and sorts the data groups. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report