我有下列R-代碼:轉換[R情節與數座標記錄2軸
x <- readClipboard()
> plot(x)
> myData = x
> myResult = ecdf(myData)
> myResult
Empirical CDF
Call: ecdf(myData)
x[1:200] = -0.031027, -0.13797, -0.16993, ..., 0.016108, 0.60295
> plot(myResult, xlim=c(0,1e1), log="x")
導致基於日誌的軸。但是,x軸是基於log 10的。我如何將其轉換爲日誌庫2?
我曾嘗試以下選項: 在基礎:
x <- 1:10
y <- 1:10
base <- 2
plot(x,y,axes=FALSE)
axis(1,at=x,labels = base^(x))
axis(2,at=y)
我所做的:
base <- 2
> plot(myResult,y,axes=FALSE)
> plot(myResult,axes=FALSE)
> axis(1,at=x,labels = base^(x))
Error in base^(x) : non-numeric argument to binary operator
> axis(1,at=myResult,labels = base^(myResult))
Error in base^(myResult) : non-numeric argument to binary operator
我也不成功地試圖做到這一點通過magicaxis:
magaxis(magaxis(unlog='x'), powbase=2)
Error in axis(side = list(family = "sans"), at = c(-0.2, 0, 0.2, 0.4, :
invalid axis number -2147483648
> magaxis((unlog='x'), powbase=2)
Error in axis(side = "x", at = c(-0.2, 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2), :
invalid axis number -2147483648
In addition: Warning message:
In axis(side = "x", at = c(-0.2, 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2), :
NAs introduced by coercion
> plot(myResult)
> magaxis((unlog='x'), powbase=2)
Error in axis(side = "x", at = c(-0.2, 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2), :
invalid axis number -2147483648
In addition: Warning message:
In axis(side = "x", at = c(-0.2, 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2), :
NAs introduced by coercion
https://stackoverflow.com/questions/34796231/how-make-the-x-axis-a-base-2-logarithm-in-r-with-magicaxis – Masoud
我收到以下錯誤:在base ^(x)中出錯:> axis(1,at = x,labels = base ^(x)) base ^(x)中的錯誤:二元運算符的非數字參數 > axis(1,at = myResult ,標籤= base ^(myResult)) 錯誤的基址^(myResult):非二進制運算符的數字參數 > –
編輯您的問題。表明您嘗試過(基於我提供的鏈接嘗試過的內容),並且還包含您獲得的錯誤。 – Masoud