r - 应用于 R 中数据帧的函数中的嵌套向量
问题描述
我有以下基本数据(问题末尾提供的输入数据):
P <- 72
E_c <- 80000
head (deflections)
L I_comp
1 60 17299.21
2 70 25760.94
3 80 32734.69
4 90 51343.59
5 100 60167.30
6 110 64887.87
其中b
定义为b = L - a
和a
是一个向量,可以定义为
a <- seq(10,L,10)
并且x
是一个嵌套序列 whitina
使得
x <- seq(1,a,1)
我已经编写了下面的函数来计算所有x
值的所有a
值的最大偏转增量。
delta_less <- function(x){
a_seq <- seq(10,L,10)
L <- x[1]
I_comp <- x[2]
X_seq <- seq(a_seq)
delta <- ((P*(L-a_seq)*X_seq)/(6*E_c*I_comp*L))*(L^2-(L-a_seq)^2-X_seq^2)
c(val = max(delta), pos = which.max(delta))
}
test <- cbind(deflections, vars = t(apply(deflections,1,delta_less)))
问题是我的代码无法识别嵌套序列。只有当我给出a_seq
一个奇异的数值时它才有效。
提供的数据:
dput(deflections)
structure(list(L = c(60, 70, 80, 90, 100, 110, 120, 130, 140,
60, 70, 80, 90, 100, 110, 120, 130, 140, 60, 70, 80, 90, 100,
110, 120, 130, 140, 60, 70, 80, 90, 100, 110, 120, 130, 140),
I_comp = c(17299.2063000114, 25760.9420686703, 32734.6949444858,
51343.5889683982, 60167.3001695375, 64887.8729936444, 83451.9473750139,
103000.852590734, 112631.744898846, 23539.3443398425, 23544.8558575609,
32808.739059987, 40880.4964809276, 60171.1172692296, 64894.6680546358,
83469.4777437875, 103114.132264558, 120223.534252571, 23539.3443398425,
25772.7904955165, 32810.8231970971, 51345.5936366056, 74673.7079705815,
80752.3694583712, 103114.132264558, 103114.132264558, 147386.853127916,
23539.3443398425, 25767.8092758621, 40881.3376639665, 55608.9342154021,
80694.6568665257, 80752.3694583712, 119068.355471205, 119402.817753462,
147386.853127916)), class = "data.frame", row.names = c(NA,
-36L))
解决方案
推荐阅读
- c++ - 虚函数调用未找到最派生的实现
- docker - 在 Druid 中配置 Kafka-indexing-service
- javascript - getServerSideProps 的正确用法?
- json - 通过其他键和值在 JSON 中查找键和值
- google-cloud-platform - 如何在没有存储桶名称的情况下访问 GCP 存储桶标签
- ios - 如何切换 UIFont 的粗体和斜体
- javascript - 如何读取控制台日志的控制台内部值
- javascript - 如何正确清理我的 package.json 文件?
- react-native - 如何使用 useQuery 将数据传递到平面列表?
- python - 熊猫合并具有相似值的行中的值