我有这个数据集并使用这个 R 代码:
library(reshape2)
library(ggplot2)
library(RGraphics)
library(gridExtra)
long <- read.csv("long.csv")
ix <- 1:14
ggp2 <- ggplot(long, aes(x = id, y = value, fill = type)) +
geom_bar(stat = "identity", position = "dodge") +
geom_text(aes(label = numbers), vjust=-0.5, position = position_dodge(0.9), size = 3, angle = 0) +
scale_x_continuous("Nodes", breaks = ix) +
scale_y_continuous("Throughput (Mbps)", limits = c(0,1060)) +
scale_fill_discrete(name="Legend",
labels=c("Inside Firewall (Dest)",
"Inside Firewall (Source)",
"Outside Firewall (Dest)",
"Outside Firewall (Source)")) +
theme_bw() +
theme(legend.position="right") +
theme(legend.title = …Run Code Online (Sandbox Code Playgroud) 我有一个 txt 文件,其中包含:
Some random
text here. This file
has multiple lines. Should be one line.
Run Code Online (Sandbox Code Playgroud)
我用:
sed '{:q;N;s/\n/:sl:/g;t q}' file1.txt > singleline.txt
Run Code Online (Sandbox Code Playgroud)
并得到:
Some random:sl:text here. This file:sl:has multiple lines. Should be one line.
Run Code Online (Sandbox Code Playgroud)
现在我想:sl:用newline (\n)字符替换模式。当我使用时:
sed 's/:sl:/&\n/g' singleline.txt
Run Code Online (Sandbox Code Playgroud)
我得到:
Some random:sl:
text here. This file:sl:
has multiple lines. Should be one line.
Run Code Online (Sandbox Code Playgroud)
如何用换行符替换模式而不是在模式后添加换行符?