我想拟合/绘制指数函数但它不起作用。对于
before_database.frame<- read.table("APD_data.txt",
header = TRUE,
sep = "",
dec="."
)
Single_APD.frame<- before_database.frame[before_database.frame$Serial_number==912009913, ]
# fit<- lm(Voltage ~ poly(Amplification,2), data=Single_APD.frame)
fit<- lm(Voltage ~ exp(Amplification), data=Single_APD.frame)
我收到:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'x'
但是“~poly(Amplification,2)”有效。怎么了?我已经搜索了错误,但解决方案对我不起作用。 谢谢!
答案 0 :(得分:1)
此答案基于对OP @Ben
的评论您使用lm(Voltage ~ exp(Amplification), data=Single_APD.frame)
:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'x'
建议您的至少一个值为NA/NaN/Inf
。你的价值范围
What is output of range(Single_APD.frame$Amplification)?
@ChiPak Sure, it's" [1] 1.00252 1903.74000
<强> ----- -----聚强>
~ poly(Amplification, 2)
没有给你一个错误,但poly
并没有按照你的预期做到。
See https://stackoverflow.com/questions/19484053/what-does-the-r-function-poly-really-do.
您可能正在寻找
val <- 1:5
2^val
这解释了为什么poly
有效。
<强> ----- -----错误强>
回到你的错误:
exp(1903.74000)
是Inf
,它解释了您的错误
答案 1 :(得分:-1)
您的数据集可能包含NULL值function getTransactions($sinceTicks) {
global $userEmailAddress;
global $userPassword;
global $accountGatewayUser;
global $accountGatewayPassword;
$format = 'JSON';
$wsdl = 'https://apps.blahblahblah.co.uk/recurring-payments/Services/Merchant.asmx?WSDL';
try {
$soapclient = new SoapClient($wsdl);
$params = array (
'userEmailAddress' => $userEmailAddress,
'userPassword' => $userPassword,
'accountGatewayUser' => $accountGatewayUser,
'accountGatewayPassword' => $accountGatewayPassword,
'format' => $format,
'sinceTicks' => $sinceTicks
);
$response = $soapclient->TransactionsSinceTicks($params);
$array = json_decode($response[0]->TransactionsSinceTicksResult, True);
return ($array['Transactions']);
}
catch(SoapFault $error) {
return json_encode($error);
}
}
,因此无法计算这些值的函数NA
。
您的数据集是否包含NA值?