2012-12-30 2 views
0

아래 데이터가 있습니다. 출판사 수가 가장 많은 저자를 결정하려면 어떻게합니까? 이상 치를 색인하는 방법?

나는이

(which(status$researchers==max(status$publications)) 

시도했지만 작동하지 않는 것 같습니다.

#PUBLICATIONS 

researchers = c("Smith", "Johnson", "Williams", "Brown", "Jones", "Miller", "Davis", "García", "Rodriguez", "Wilson", "Martinez", "Anderson", "Taylor", "Thomas", "Hernandez", "Moore", "Martin", "Jackson", "Thompson", "White", "Lopez", "Lee", "Gonzalez", "Harris", "Clark", "Lewis", "Robinson", "Walker", "Perez", "Hall", "Young", "Allen", "Sanchez", "Wright", "King", "Scott", "Green", "Baker", "Adams", "Nelson", "Hill", "Ramirez", "Campbell", "Mitchell", "Roberts", "Carter", "Phillips", "Evans", "Turner", "Stapel", "Torres", "Parker", "Collins", "Edwards", "Stewart", "Flores", "Morris", "Nguyen", "Murphy", "Rivera", "Cook", "Rogers", "Morgan", "Peterson", "Cooper", "Reed", "Bailey", "Bell", "Gomez", "Kelly", "Howard", "Ward", "Cox", "Diaz", "Richardson", "Wood", "Watson", "Brooks", "Bennett", "Gray", "James", "Reyes", "Cruz", "Hughes", "Price", "Myers", "Long", "Foster ", "Sanders", "Ross", "Morales", "Powell", "Sullivan", "Russell", "Ortiz", "Jenkins", "Gutierrez", "Perry", "Butler", "Barnes", "Fisher", "De Jong", "Jansen", "De Vries", "vd Berg", "Van Dijk", "Bakker", "Janssen", "Visser", "Smit", "Meijer", "De Boer", "Mulder", "De Groot", "Bos", "Smeesters", "Vos", "Peters", "Hendriks", "Van Leeuwen", "Dekker", "Brouwer", "De Wit", "Dijkstra", "Smits", "De Graaf", "Van der Meer", "Muller", "Schmidt", "Schneider", "Fischer", "Meyer", "Weber", "Schulz", "Wagner", "Becker", "Hoffmann", "Wagemakers", "Molenaar", "Jansen", "White", "Bargh", "Dijksterhuis", "Poldermans", "Kanazawa", "Lynne", "Ling", "Vorst", "Borsboom", "Wicherts") 

articles = data.frame(cbind(researchers, publications)) 
write.table(articles, file = "scientific status.txt", sep = " ") 

status = read.table("scientific status.txt", header = TRUE, sep = "", quote = "\"'")  
+0

데이터 작성 방법은 생각하지 않습니다. '{write, read} .table' 단계는 여기에 관련되지 않습니다. 데이터 샘플을 보내 주시면 훨씬 더 유용 할 것입니다. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – flodel

+0

글쎄, 나 데이터를 만들 수있게 만드는 것이 유용 할 것이라고 생각했습니다. – mats

+0

하지만 '상태'의 내용은 무엇입니까? 정수가 아니면 않는 한 성냥을 얻을 수 없습니다. '연구자'벡터에는 숫자가 없기 때문에 '최대'는 그 문자열로 흥미로운 일을 할 것입니다. –

답변

2

일반적인 응답은 아니지만 여기서는 복제본을 추출해야합니다.

researchers[duplicated(researchers)] 
[1] "Jansen" "White" ## this 2 authors have 1 publications more than others! 

는 예를 들어,이 작업을 수행 할 수있는 ouliers를 보려면 :

plot(table(researchers)) 

enter image description here

2

데이터가 무엇을 나타내는 지 분명하지 않다. 이미 저자마다 집계되는 경우, 즉,이 저자 당 하나 개의 행이하고 publications 열이 출판물의 수를 포함는 수행

status$researchers[which.max(status$publications)] 

대신하는 경우, 데이터가 집계되지 않은, 즉, 하나의 당이 문서를 작성하면 다음을 할 수 있습니다 :

tail(sort(table(status$researchers)), 1) 
+0

감사. 이것은 도움이됩니다. 기사를 30 권이나 발표 한 연구원의 이름을 알고 싶다면 어떻게해야할까요? – mats

+0

데이터가 이미 집계 된 경우 하위 집합 (status, publications> = 30)입니다. 집계되지 않은 경우 'which (table (professionals)> = 30'. – flodel

+0

데이터는 실제로 집계됩니다. – mats

관련 문제