In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to integrate data with melt function". In daily operation, I believe many people have doubts about how to use melt function to integrate data. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to integrate data with melt function". Next, please follow the editor to study!
With the help of reshape2 package melt function, the data is shaped to change the way of data combination.
Reshape2 package melt function is used to integrate data. It is common to integrate data in the process of drawing images using ggplot2 package. Melt () is used as follows:
Load R package and case data
Library ('reshape2') dat type sample1 sample2 sample1 sample21 A 6.332968 5.367671 5.171107 5.5337542 A 9.368328 7.286253 6.232718 6.1523933 B 6.674348 5.217053 5.320568 6.1136184 B 4.127901 3.875520 4.924498 4.9609355 C 5.192845 6.679444 7.140883 5.9595686 C 6.652865 6.127819 4.228142 5.0789037 D 7.829350 5.091166 5.793514 4.8711038 D 6.995062 7.942029 6.347785 5.223206
The default parameter integrates the same type of data.
Melt (dat) Using type as id variables type variable value1 A sample1 6.3329682 A sample1 9.3683283 B sample1 6.6743484 B sample1 4.1279015 C sample1 5.1928456 C sample1 6.6528657 D sample1 7.8293508 D sample1 6.9950629 A sample2 5.36767110 A sample2 7.28625311 B sample2 5.21705312 B sample2 3.87552013 C sample2 6.67944414 C sample2 6.12781915 D sample2 5.09116616 D sample2 7.94202917 A sample1 6.33296818 A sample1 9.36832819 B sample1 6.67434820 B sample1 4.12790121 C sample1 5.19284522 C sample1 6.65286523 D sample1 7.82935024 D sample1 6.99506225 A sample2 5.36767126 A sample2 7.28625327 B sample2 5.21705328 B sample2 3.87552029 C sample2 6.67944430 C sample2 6.12781931 D sample2 5.09116632 D sample2 7.942029
Specify the columns to integrate (select the columns that are not integrated). For example, if the first sample data is not integrated, id can also be written as var.ids.
Melt (dat,id=c ("type", "sample1") type sample1 variable value1 A 6.332968 sample2 5.3676712 A 9.368328 sample2 7.2862533 B 6.674348 sample2 5.2170534 B 4.127901 sample2 3.8755205 C 5.192845 sample2 6.6794446 C 6.652865 sample2 6.1278197 D 7.829350 sample2 5.0911668 D 6.995062 sample2 7.942029
Name the merged column, the merged variable variable.name, and the variable value value.name
Melt (dat,id=c ("type", "sample1"), variable.name = "Samples", value.name = "Expression") type sample1 Samples Expression1 A 6.332968 sample2 5.3676712 A 9.368328 sample2 7.2862533 B 6.674348 sample2 5.2170534 B 4.127901 sample2 3.8755205 C 5.192845 sample2 6.6794446 C 6.652865 sample2 6.1278197 D 7.829350 sample2 5.0911668 D 6.995062 sample2 7.942029 The study on "how to integrate data with melt function" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.