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 > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize data collection in R language". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "R language how to achieve data collection" bar!
Row summation, average and frequency
RowSums, colSums,rowMeans, and colMeans can be simply understood as summing or averaging by row or column. Table takes numbers or characters as factors to calculate the frequency, all of which are quite simple:
1. > an a
3. > rowSums (a)
4. [1] 6 6 6
5. > colSums (a)
6. [1] 3 6 9
7. > table (a)
For multidimensional arrays, the use of rowSums,colSums, rowMeans, and colMeans is a little more complicated. Their parameters are:
1. ColSums (x, na.rm = FALSE, dims = 1)
2. RowSums (x, na.rm = FALSE, dims = 1)
3. ColMeans (x, na.rm = FALSE, dims = 1)
4. RowMeans (x, na.rm = FALSE, dims = 1)
Where dims is an integer, indicating which dimension or dimensions are regarded as rows or columns, for row statistical functions, dims+1 and subsequent dimensions are regarded as rows, and for col functions, dims and previous dimensions (1:dims) are regarded as columns:
1. > b b
3. > rowSums (b)
4. [1] 18 18 18
5. > rowSums (bsperm dimsroom1)
6. [1] 18 18 18
7. > rowSums (bsperm dimswatches 2)
8. [, 1] [, 2] [, 3]
9. [1,] 6 6 6
10. [2,] 6 6 6
11. [3,] 6 6 6
12. > colSums (b)
13. [, 1] [, 2] [, 3]
14. [1,] 3 6 9
15. [2,] 3 6 9
16. [3,] 3 6 9
17. > colSums (bsperm dimsgiving 2)
18. [1] 9 18 27
Table can count the frequency of occurrence of numbers, as well as other data types that can be seen as factors:
1. > table (b)
2. B
3. 1 2 3
4. 9 9 9
5. > c c
7. [1] "a"c"b"d"a"e"d"e"c"a"
8. > table (c)
9. C
10. A b c d e
11. 3 1 2 2 2
If there is more than one parameter, their length should be the same, and the result is a frequency table of different factor combinations:
1. > ab table (aPermie b)
4. B
5. An A B C
6. A 0 3 1
7. B 3 0 1
8. C 1 1 2
At this point, I believe you have a deeper understanding of "R language how to achieve data collection", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.