我随着时间的推移采样了一些信号,我使用连续线在R中绘制.另外,我想强调一下情节中的几个具体时间范围.
我目前的方法是绘制具有适当宽度和水平位置的全高度透明矩形,以匹配时间范围.我认为这是一个很好的表现形式,因为它清楚地区分了范围内的点和它之外的点; 但有更好的吗?
问题的第二个实际部分.现在我正在绘制这样的信号:
p <- ggplot(data=gs, mapping=aes(x=frameno, y=value, col=variable)) +
geom_line()
p
Run Code Online (Sandbox Code Playgroud)
我试图手动绘制alpha混合矩形:
p + geom_rect(aes(xmin=600, xmax=650, ymin=-3, ymax=3),
colour=alpha("grey20", 0.5), fill.alpha=0.5)
Run Code Online (Sandbox Code Playgroud)
- 到目前为止没有成功.任何提示?
我有一个如下所示的数据框,当我使用xlsx包将其导出到excel文件时,我真的想删除行名称.
bd <- data.frame(id = 1:200, A = c(rep("One", 100), rep("Two", 100)),
B = c(rep(1,50), rep(0, 50), rep(1, 50), rep(0, 50)))
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用下面的命令,但它将它们保存在excel文件的第一列中.
bd <- data.frame(id = 1:200, A = c(rep("One", 100), rep("Two", 100)),
B = c(rep(1,50), rep(0, 50), rep(1, 50), rep(0, 50)), row.names=NULL)
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
我有data.frame annot定义为:
annot <- structure(list(Name = c("dd_1", "dd_2", "dd_3","dd_4", "dd_5", "dd_6","dd_7"), GOs =
c("C:extracellular space; C:cell body; P:cell migration process; P:NF/ß pathway",
"C:Signal transduction; C:nucleus; F:positive regulation; P:single organism; P:positive(+) regulation",
"C:cardiomyceltes; C:intracellular pace; F:putative; F:magnesium ion binding; F:calcium ion binding; P:visual perception; P:blood coagulation",
"F:poly(A) RNA binding; P:DNA-templated transcription, initiation",
"C:ULK1-ATG13-FIP200 complex; F:histone-arginine N-methyltransferase activity; P:single-organism cellular process",
"F:3'-5' DNA helicase activity; P:acetate-CoA ligase activity",
"F:UDP-N-acetylmuramoylalanyl-D-glutamyl-2,6-diaminopimelate-D-alanyl-D-alanine ligase activity; P:oxidoreductase activity, acting on the aldehyde or oxo group of …Run Code Online (Sandbox Code Playgroud) 我需要将shapefile转换为栅格格式.
我在R包"raster"中使用了"rasterize"功能,但结果看起来不正确.
tst <- rasterize(shpfile, r, fun="count")
Found 5 region(s) and 5 polygon(s)
Run Code Online (Sandbox Code Playgroud)
没有发生记录的网格:
range(tst[],na.rm=TRUE)
[1] Inf -Inf
Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
sum(tst[],na.rm=TRUE)
[1] 0
Run Code Online (Sandbox Code Playgroud)
我写的R脚本:
# download the GIS shape file
download.file("http://esp.cr.usgs.gov/data/little/abiebrac.zip",
destfile = "abiebrac.zip")
# unzip
unzip("abiebrac.zip")
# Read shapefile into R
library(maptools)
shpfile <- readShapePoly("abiebrac")
extent(shpfile)
# mapping
plot(shpfile)
library(maps)
map("world",xlim=c(-180,-50),ylim=c(7,83),add=FALSE)
plot(shpfile,add=TRUE,lwd=10)
# rasterize
library(raster)
GridSize <- …Run Code Online (Sandbox Code Playgroud) 我的可重复数据如下:
x <- c(7232L, 6274L, 8163L, 7421L, 6362L, 7206L, 7600L, 7421L, 9381L,
8173L, 7473L, 6318L, 5360L, 4732L, 7249L, 6435L, 5556L, 6256L,
6543L, 6113L, 8288L, 7438L, 6272L)
y <- c(1.649, -0.27, 0.149, 0.504, -0.634, 1.067, -1.243, 0.539, -2.399,
0.281, 0.217, 0.371, -0.937, -2.238, -0.71, 0.295, -0.289, -0.271,
0.944, 0.724, -0.149, 0.204, 1.932)
Run Code Online (Sandbox Code Playgroud)
绘制这个:
plot(y,x)
Run Code Online (Sandbox Code Playgroud)
给出一个简单的散点图:

如何在上面的散点图中添加最适合的曲线?我遇到了使用该loess功能的东西,但这似乎不起作用.
我是R的新手,我一直在寻找这个问题几个小时.任何帮助将不胜感激.
谢谢