-3
使用數據表時,數字從左到右排列,而不是從右到左排列。我也將它轉換爲數字。它爲什麼這樣做?請參閱*號碼 它與所有列相同。DataTable通過在列中從左到右排列數字
下面是一個例子:950應該是第一個,而不是96.67
Items RN.2015 RN.2016 Change.RN
London 30 59 **96.67**
Tokyo 2 21 **950**
Paris 2 21 950
Seoul 2 21 950
New York20 39 95
Orlando 18 35 94.44
Nice 3 31 **933.3**
代碼在反應:
library(dplyr)
fileInfo$RN <- as.numeric(as.character(fileInfo$RN))
perChange<-fileInfo %>%
group_by_(input$selCol) %>%
summarise(
RN.2015 = sum(RN[Year=="2015"]),
RN.2016 = sum(RN[Year=="2016"])
)%>%
mutate(
Change.RN = delt(RN.2015,RN.2016)
)
功能
delt <- function(x,y) {ifelse(is.finite((y-x)/x*100),paste0(formatC((y-x)/x*100),"%"),"")}
數據:
Data <- data.frame(
Items = c("London","Tokyo","Paris","Seoul","New York","Orlando","Nice"),
RN.2015 = c(30,2,2,2,20,18,3),
RN.2016 = c(59,21,21,21,39,35,31)
)
[如何使一個偉大的R可重現的例子?](http://stackoverflow.com/questions/5963269) – zx8754
代碼和粘貼的文本輸入數據不匹配。 – zx8754
謝謝downvoting @ zx8754 – JamAndJammies