我有下列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