• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Sep 18th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
2.
4.
5. # assign 9th column of data frame to a vector
6. cit_num_vector <- articles[,9]
7.
8. # filter out NA values
9. cit_num_vector <- cit_num_vector[!is.na(cit_num_vector)]
10.
11. # sort the vector
12. cit_num_vector_sorted <- sort(cit_num_vector)
13.
14. Np <- length(cit_num_vector_sorted)
15.
16. # The resulting table will have Np rows and 2 columns
17. res_table <- matrix(0:0, nrow = Np, ncol = 2)
18.
19. curr_val <- 0
20. c <- 1
21.
22. # Cycing through cit_num_vector
23. for (i in 1:length(cit_num_vector_sorted)) {
24.     # If it is a next unique value in the vector
25.     if (curr_val != cit_num_vector_sorted[i]) {
26.         # assign the first row of c-th column
27.         res_table[c, 1] <- cit_num_vector_sorted[i]
28.
29.         # Np in this case will be equal to Np - i + 1
30.         res_table[c, 2] <- Np - i + 1
31.
32.         # Assign a new value to curr_val to check
33.         # next values for uniqueness
34.         curr_val <- cit_num_vector_sorted[i]
35.
36.         # Add 1 to counter variable
37.         c <- c + 1
38.     }
39. }
40.
41. # Cycling through res_table
42. for (i in 1:Np) {
43.     cit_num <- res_table[i, 1]
44.     count <- res_table[i, 2]
45.     if (cit_num > count) {
46.         break
47.     }
48.     res <- res_table[i, 1]
49. }
50.
51. print(res)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top