r프로그래밍 과제이신데 혹시 어떻게 푸시는지 아시는 분 있나요?
r고수님들 부탁드려요 ㅠㅠㅠㅠ
아래와 같이 reshape2와 stringr 라이브러리를 사용하는 것이 핵심인 것 같습니다.
library(reshape2) library(stringr) new_eurodist <- subset(melt(as.matrix(eurodist))) new_eurodist$Var1 <- paste(new_eurodist$Var1, "&") new_eurodist$Var2 <- paste(new_eurodist$Var2, "사이의 거리:") new_eurodist
결과는, 아래와 같이 출력됩니다.
1 Athens & Athens 사이의 거리: 0 2 Barcelona & Athens 사이의 거리: 3313 3 Brussels & Athens 사이의 거리: 2963 4 Calais & Athens 사이의 거리: 3175 5 Cherbourg & Athens 사이의 거리: 3339 6 Cologne & Athens 사이의 거리: 2762 7 Copenhagen & Athens 사이의 거리: 3276 8 Geneva & Athens 사이의 거리: 2610 ... ... ...
아래와 같이 reshape2와 stringr 라이브러리를 사용하는 것이 핵심인 것 같습니다.
결과는, 아래와 같이 출력됩니다.