我用以下代码创建一个向量。我需要找到在顶部定义的某些数字在矢量中的位置。
由于以下浮点错误不适用于某些值。哪个功能可以与what函数一起使用?
colourlength=25000
# Set up blank data frame
colourscale = data.frame(matrix(NA, nrow=colourlength+1, ncol=2))
#First column for later join, contains lr values
colourscale[[1]] = seq(from=0, to=2.5, length.out = colourlength+1)
n1=.50 # green
n2=.65 # yellow
n3=.7 # red
n4=.75 # purple
n5=.85 # pink
n6=1.5 # grey
n7=2.5 # black
length1 = which(n1==colourscale[1])
length2 = which(n2==colourscale[1])
length3 = which(n3==colourscale[1])
length4 = which(n4==colourscale[1])
length5 = which(n5==colourscale[1])
length6 = which(n6==colourscale[1])
length7 = which(n7==colourscale[1])