list - 点火情节元素列表
解决方案
这可以在 TERR 数据函数中完成。我不知道您将 Spotfire 与 TERR 集成起来有多舒服,例如这里有一个介绍视频(演示从大约 7 分钟开始):
https://www.youtube.com/watch?v=ZtVltmmKWQs
考虑到这一点,我在没有加载任何库的情况下编写了脚本,因此它非常冗长和明确,但希望更容易一步一步地遵循。我确信有一种更优雅的方法,并且有更好的方法可以使其灵活地使用列名,但这是一个开始。
您的输入将是一个数据表(dt,原始数据),输出一个新数据表(dt.out,转换后的数据)。所有列名(和一些值)都在脚本中显式处理(因此,如果您更改它们,它将不起作用)。
#remove the []
dt$Values=gsub('\\[|\\]','',dt$Values)
#separate into two different data frames, one for time and one for temperature
dt.time=dt[dt$Description=='time',]
dt.temperature=dt[dt$Description=='temperature',]
#split the columns we want to separate into a list of vectors
dt2.time=strsplit(as.character(dt.time$Values),',')
dt2.temperature=strsplit(as.character(dt.temperature$Values),',')
#rearrange times
names(dt2.time)=dt.time$object
dt2.time=stack(dt2.time) #stack vectors
dt2.time$id=c(1:nrow(dt2.time)) #assign running id for merging later
colnames(dt2.time)[colnames(dt2.time)=='values']='time'
#rearrange temperatures
names(dt2.temperature)=dt.temperature$object
dt2.temperature=stack(dt2.temperature) #stack vectors
dt2.temperature$id=c(1:nrow(dt2.temperature)) #assign running id for merging later
colnames(dt2.temperature)[colnames(dt2.temperature)=='values']='temperature'
#merge time and temperature
dt.out=merge(dt2.time,dt2.temperature,by=c('id','ind'))
colnames(dt.out)[colnames(dt.out)=='ind']='object'
dt.out$time=as.numeric(dt.out$time)
dt.out$temperature=as.numeric(dt.out$temperature)
盖亚
推荐阅读
- javascript - jQuery 选择器在动态插入的数据中不起作用
- c# - 为什么不能用 Func 的参数直接调用函数呢?
- elixir - 在 Elixir 和 phoenix Web 应用程序中限制用户从变更集中删除
- python - 使用过滤器处理素数和奇数 Python 的高阶函数
- meteor - 提供反应数据源
- node.js - 无法使用我的 PC IP 地址访问 Mongodb Atlas
- java - 匹配 html 标签字符串时的错误值
- javascript - how to pass values from a formgroup to another formgroup realtime as a two way data binding in a reactive form?
- python - 我想用python制作基本的房地产脚本
- python - 如何找到具有一些缺失值的数据帧的每一行的总和