Rstudio -Error: Client error: (401) Unauthorized No such user, can't open files.credentials, ./config etc
Rstudio -Error: Client error: (401) Unauthorized No such user, can't open files.credentials, ./config etc
当我 运行 Rstudio 中的 R 代码时,出现以下错误。怎么了?'
Error: Client error: (401) Unauthorized No such user In addition: Warning messages: 1: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.credentials': No such file or directory 2: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.config': No such file or directory 3: You need a plotly username. See help(signup, package = 'plotly') 4: Couldn't find username 5: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.credentials': No such file or directory 6: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.config': No such file or directory 7: You need an api_key. See help(signup, package = 'plotly') 8: Couldn't find api_key
R代码:
library("plotly")
a = read.csv('/Users/i073341/Library/CloudStorage/OneDrive-SAPSE/Data Analysis/result/Opportunity/20220207-151923/cleanSankey.csv', header=TRUE, sep=',')
node_names <- unique(c(as.character(a$source), as.character(a$target)))
nodes <- data.frame(name = node_names)
links <- data.frame(source = match(a$source, node_names) - 1,
target = match(a$target, node_names) - 1,
value = a$value)
#Plot
p <- plot_ly(type='sankey',
orientation = "h",
node = list(
label = node_names,
color = "grey",
pad = 15,
thinkness = 20,
line = list(color = "grey", width = 0.5)),
link = list(
source = links$source,
target = links$target,
value = links$value))
plotly_IMAGE(p, out_file="out.png")
如果我删除最后一行代码 plotly_IMAGE(p, out_file="out.png"),则没有错误。
plotly_IMAGE
用于使用 plotly chart studio. You need an api_key for this to work. See this 或 help(signup, package = 'plotly')
.
将图形导出为静态图像
如果要在本地 PC 上导出静态图像,可以使用 plotly::save_image(p, "plot.png")
。
为了 save_image
工作,请考虑以下事项:
kaleido() requires the kaleido python package to be usable via the
reticulate package. Here is a recommended way to do the installation:
install.packages('reticulate') reticulate::install_miniconda()
reticulate::conda_install('r-reticulate', 'python-kaleido')
reticulate::conda_install('r-reticulate', 'plotly', channel =
'plotly') reticulate::use_miniconda('r-reticulate')
作为替代方案,您可以使用
htmlwidgets::saveWidget(partial_bundle(p), file = "plot.HTML", selfcontained = TRUE)
将您的图表保存为独立的 HTML 文件(例如,已完成 )
当我 运行 Rstudio 中的 R 代码时,出现以下错误。怎么了?'
Error: Client error: (401) Unauthorized No such user In addition: Warning messages: 1: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.credentials': No such file or directory 2: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.config': No such file or directory 3: You need a plotly username. See help(signup, package = 'plotly') 4: Couldn't find username 5: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.credentials': No such file or directory 6: In open.connection(con, "rb") : cannot open file '/Users/i073341/.plotly/.config': No such file or directory 7: You need an api_key. See help(signup, package = 'plotly') 8: Couldn't find api_key
R代码:
library("plotly")
a = read.csv('/Users/i073341/Library/CloudStorage/OneDrive-SAPSE/Data Analysis/result/Opportunity/20220207-151923/cleanSankey.csv', header=TRUE, sep=',')
node_names <- unique(c(as.character(a$source), as.character(a$target)))
nodes <- data.frame(name = node_names)
links <- data.frame(source = match(a$source, node_names) - 1,
target = match(a$target, node_names) - 1,
value = a$value)
#Plot
p <- plot_ly(type='sankey',
orientation = "h",
node = list(
label = node_names,
color = "grey",
pad = 15,
thinkness = 20,
line = list(color = "grey", width = 0.5)),
link = list(
source = links$source,
target = links$target,
value = links$value))
plotly_IMAGE(p, out_file="out.png")
如果我删除最后一行代码 plotly_IMAGE(p, out_file="out.png"),则没有错误。
plotly_IMAGE
用于使用 plotly chart studio. You need an api_key for this to work. See this 或 help(signup, package = 'plotly')
.
如果要在本地 PC 上导出静态图像,可以使用 plotly::save_image(p, "plot.png")
。
为了 save_image
工作,请考虑以下事项:
kaleido() requires the kaleido python package to be usable via the reticulate package. Here is a recommended way to do the installation:
install.packages('reticulate') reticulate::install_miniconda() reticulate::conda_install('r-reticulate', 'python-kaleido') reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly') reticulate::use_miniconda('r-reticulate')
作为替代方案,您可以使用
htmlwidgets::saveWidget(partial_bundle(p), file = "plot.HTML", selfcontained = TRUE)
将您的图表保存为独立的 HTML 文件(例如,已完成