In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of R language how to delete duplicate data, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this R language article on how to delete duplicate data. Let's take a look.
R methods for deleting duplicate data, including duplicated and unique return logical values when operating on duplicated, elements of a vector or rows of data boxes. Take the following data box as an example: dat A B C D1 a b a c2 c k b D3 c k c c4.
R methods for deleting duplicate data, including duplicated and unique
For duplicated, when you operate on the element of a vector or the row of a data box, a logical value is returned. Take the following data box as an example:
Dat A B C D1 a b a c2 c k b d3 c k c c4 d e q K5 e f g L6 h g h Q7 j f q K8 a b a c9 e f g L10 o o l m duplicated (dat) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE
Dat is a ten-row data box in which rows 8 and 1 repeat, and rows 9 and 5 repeat, so the 8th and 9th of the return values are TRUE, so you can exclude as TRUE, that is, duplicate data, as shown below, and take only the result of the first occurrence of the data.
Dat [! duplicated (dat),] A B C D1 a b a c2 c k b d3 c k c c4 d e q K5 e f g L6 h g h Q7 j f q K10 o o l m
Duplicated can judge duplicate data based on specific regions, such as:
Dat [! duplicated (dat [, c ("A", "B")]),] A B C D1 a b a c2 c k b D4 d e q K5 e f g L6 h g h Q7 j f q K10 o o l m dat [! duplicated (dat [1:8,]),] A B C D1 a b a c2 c k b d3 c k c c4 d e q K5 e f g l6 h g h Q7 j f q K9 e f g l10 o o l m dat [! duplicated (dat [1Rd 8L c ("A") "B")]),] A B C D1 a b a c2 c k b d4 d e q K5 e f g L6 h g h Q7 j f q K9 e f g L10 o o l m
Unique processes the vector and the data box, and directly returns the result after deletion and repetition, and takes the result of the first occurrence:
Unique (dat) A B C D1 a b a c2 c k b d3 c k c c4 d e q K5 e f g L6 h g h Q7 j f q K10 o o l m
As a result of both treatments, the original row name has not changed.
This is the end of the article on "how to remove duplicate data in R language". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to remove duplicate data in R language". If you want to learn more, you are welcome to 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.
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.