r - 如何将 R 图附加到 csv 文件中的给定列?
问题描述
我知道如何使用 R 将“说数字”附加到 csv 文件。我想要的是将相应的图表也粘贴到相应列中的同一文件中。这是我尝试过的代码,但失败了。请帮忙。
library(muhaz)
library(readr)
ball_data <- read_csv("C:/Users/dovini jayasinghe/Desktop/Cricket/ball data.csv")
attach(ball_data)
#View(ball_data)
for(i in 1:3){
fit <- muhaz(times = scoreValue[help_index2==i],
delta = Censored[help_index2==i],
bw.method="local",
kern="epanechnikov",
max.time=max(scoreValue[help_index2==i]))
graph <- plot(fit)#draws the plot
max_x <- max(fit$pin$times)
#data frame excluding the graph
df <- data.frame("Ball Number" = i,
"Maximum Score" = max_x
)
#if we need the graph, I think the code is this way
# df <- data.frame("Ball Number" = i,
# "Maximum Score" = max_x,
# "Graph" = graph)
write.table(df,
'C://Users//dovini jayasinghe//Desktop//Cricket//hazard_i_th_ball.csv',
row.names = FALSE,
col.names = FALSE,
sep = ",",
append = TRUE)
}
具体来说,我需要一个像这样的表(一个csv文件)
球号 | 最高分 | 图形 |
---|---|---|
1 | 4 | 图 1 的图像 |
2 | 1 | 图 2 的图像 |
3 | 3 | 图 3 的图像 |
解决方案
推荐阅读
- asp.net - C# ASP.NET Core 2 中的安全网络聊天
- objective-c - 将 A 类型的属性传递给方法(5 个可能的属性作为输入) - 区分输入
- javascript - prevent form submission if form fields are not filled
- angular - 在第三个服务角度 4 中注入两个服务
- postgresql - 是否也在 WSL 中使用安装在 Windows 中的 PostgreSQL?
- eclipse - PyDev 不会自动完成我导入的模块
- python - 为循环中的列打印 value_counts
- go - 如何在gorm中获取结构(结构内部)值
- instagram - 使用 Instagram 的 Watson Assistant
- python - (Python 2.7) 获取 UI 标题栏大小