我看到一个错误"尺寸数量不正确"当我在下面运行我的代码。 " MYDATA"是一个带有变量的数据框,"深度","年"和"无功"
depth var year
75.701 3.314472209 1964
75.711 6.184566981 1964
75.721 11.63833113 1964
75.731 10.92470382 1964
75.741 6.884034653 1964
75.751 3.567515285 1964
75.761 2.07174425 1964
75.771 2.829011606 1964
75.781 4.80560514 1964
75.791 4.18529085 1964
75.801 3.361608052 1964
75.811 3.711773806 1964
75.821 4.059657671 1964
75.831 7.676827986 1964
75.841 6.924370206 1963
75.851 16.98705556 1963
75.861 21.56234523 1963
75.871 8.618156376 1963
75.881 3.487789744 1963
75.891 2.422058997 1963
75.901 5.038429763 1963
75.911 13.29836041 1963
75.921 20.6988331 1963
75.931 22.90022852 1963
75.941 27.97886558 1963
75.951 50.38703329 1963
75.961 61.4282796 1963
75.971 40.49568815 1963
75.981 23.20749659 1963
75.991 14.75910651 1963
76.001 20.02729577 1963
76.011 36.53041814 1963
76.021 47.07261365 1963
76.031 58.02382514 1963
76.041 55.89395862 1963
library(dplyr)
# I compute percentiles of "depth" every "year". "percrank" is created
mydata.rank<- mydata %>%
group_by(year) %>%
mutate(percrank=rank(depth)/length(depth))
# Here, I summarize "var" when 0.25<"percrank"<0.75. But I see error.
mydata.rank %>% group_by(year) %>%
summarize(var=var[which(percrank<=0.75 | percrank>=0.25),])
# error: incorrect number of dimensions
mydata.rank %>% na.omit() %>% group_by(year) %>%
summarize(var=var[which(percrank<=0.75 | percrank>=0.25),])
# error: incorrect number of dimensions
我认为,&#34; NA&#34;是问题,但是当&#34; na.omit&#34;应用,同样的错误。
任何建议都会有所帮助。
另外,我需要得到&#34; var&#34;的分数(第10,25,50,70,9),而不是总结。每当0.25 <&#34; percrank&#34; <0.75时。
非常感谢你的帮助。
LIM