Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.83 KB | None | 0 0
  1. articles <- read.csv(url("https://raw.githubusercontent.com/go95/big_data_intro/master/Abdulkadiroglou.csv"))
  2. citationNumbers <- articles[,9]
  3. citationNumbersSorted <- sort(citationNumbers)
  4. len <- length(citationNumbersSorted)
  5. indexMatrix <- matrix(0:0, nrow = len, ncol = 2)
  6. currentValue <- 0
  7. counter <- 1
  8. for (i in 1:length(citationNumbersSorted)) {
  9.     if(!is.na(citationNumbersSorted[i]) && currentValue != citationNumbersSorted[i]) {
  10.         indexMatrix[counter, 1] <- citationNumbersSorted[i]
  11.         indexMatrix[counter, 2] <- len - i + 1
  12.         currentValue <- citationNumbersSorted[i]
  13.         counter <- counter + 1
  14.     }
  15. }
  16. hirschIndex <- indexMatrix[1,1]
  17. for(i in 2:length(indexMatrix)) {
  18.     if(indexMatrix[i, 1] > indexMatrix[i, 2]) {
  19.         break
  20.     }
  21.     hirschIndex <- indexMatrix[i, 1]
  22. }
  23. print(hirschIndex)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement