在尝试使用闪亮的公式进行计算时,出现错误。作为一个简短示例,电抗值通过输入按钮输入。假设它包含一个字符向量(例如Age)。可从素食主义者图书馆中获得Adonis。
values <-reactiveValues(data = NULL)
adof <- function()({
#metadata is a dataframe with columns variables for each sample (Age,gender...)
metadata <- as(sample_data(phyloseq), "data.frame")
dis <- phyloseq::distance(phyloseq, method="uunifrac")
#dis is a distance matrix
ad <- data.frame(adonis2(dis ~ values$data,data=metadata)
}
#Results
Error:object of type 'closure' is not subsettable
但是,如果我使用以下公式,它将起作用。 (用字符向量改变反应值)
adof <- function()({
metadata <- as(sample_data(phyloseq), "data.frame")
dis <- phyloseq::distance(phyloseq, method="uunifrac")
ad <- data.frame(adonis2(dis ~ Age ,data=metadata))
cat("Selected:"values$data)
ad
}
# Results
selected: Age
Df SumOfSqs R2 F Pr..F.
Age 4 9.863528 0.2394484 21.09395 0.001
Residual 268 31.329187 0.7605516 NA NA
Total 272 41.192715 1.0000000 NA NA
我的反应性值的馈送方式是通过观察语句
observe({
# Fed reactive value with my selected radiobutton
values$data = input$data
})
答案 0 :(得分:1)
问题在于Total Costs
Array
(
[metadata] => Array
(
[material] => ABS
[color] => #000000
[infillPercentage] => 30
[layerHeight] => 0.254
[supportRemoval] => false
[vaporPolishing] => false
[shipping] => delivery
[rushPrinting] => true
)
[totalWeight] => Array
(
[amount] => 19.8
[unit] => grams
)
[totalTime] => Array
(
[amount] => 3489
[unit] => seconds
)
[costs] => Array
(
[printTime] => Array
(
[amount] => 3.88
[calculation] => 3489 seconds * (1 hour)/(60*60 seconds) * $4.00 USD/hour
[unit] => USD
)
[material] => Array
(
[amount] => 3.96
[calculation] => 19.80 grams * 0.20 USD/g
[unit] => USD
)
[delivery] => Array
(
[amount] => 6.00
[calculation] => 5.80 USD base + 19.80 grams * 0.01 USD/g
[unit] => USD
)
)
[subtotal] => Array
(
[amount] => 13.84
[calculation] => 3.88 USD printTime + 3.96 USD material + 6.00 USD delivery
[unit] => USD
)
[total] => Array
(
[amount] => 13.84
[calculation] => 13.84 subtotal
[unit] => USD
)
)
API Response
Array
(
[0] => Array
(
[estimatedCost] => Array
(
[amount] => 7.84
[unit] => USD
[calculation] => 0.97 hours * $4.00/hour + 19.80 grams * $0.20/gram
)
[filamentUsed] => Array
(
[amount] => 19.8
[unit] => grams
[calculation] => (1.75mm/2)^2 * 3.1416 * 7917mm * 1cm^3/1000mm^3 * 1.04g/cm^3
)
[gCodeLink] => http://www.3dpartprice.com/gCodeOutput/CactusBody.stl.gcode
[printDuration] => Array
(
[amount] => 3489
[unit] => seconds
[formatted] => 58 minutes, 9 seconds
)
[sliceDuration] => Array
(
[amount] => 0.72
[unit] => seconds
)
[slicer] => cura
[stlFileLink] => http://www.3dpartprice.com/stlUploads/CactusBody.stl
[stlFilename] => CactusBody.stl
[stlFilesize] => 29484
[stlTriangleCount] => 588
[stlVolume] => Array
(
[amount] => 30.25
[unit] => cm
[formatted] => cm^3
)
)
)
是包含字符串的变量。您必须先将其转换为公式,然后才能使用它。
尝试这样的事情。
<form enctype="multipart/form-data" id="formprint" action="http://3dpartprice.com/3dpartpricelib/api-caller.php" method="post">
<input type="radio" name="material" value="ABS"> ABS <br>
<input type="radio" name="material" value="PLA"> PLA
<!-- ABS PLA -->
<input type='radio' name='color' value='#000000'> White <br>
<input type='radio' name='color' value='#FFFFFF'> Black <br>
<!-- value - 000000 or FFFFFF class - ABS or PLA -->
<input type="text" name="layerHeight" value="0.254">
<!-- 0.1 to 0.4 -->
<input type="text" name="infillPercentage" value="30">
<!-- (0 to 100%) -->
<input type="file" name="stlFiles[]" multiple>
<input type="submit" name="" value="Submit">
</form>
希望这会有所帮助!