我试图在今年发表在Nature上的一篇文章中对图2d-f进行类似的绘图.它基本上是一个半箱图,另一半有点.
任何人都可以给我一些提示吗?非常感谢你!
这些是我的数据和代码,它们生成带有内部点的完整框
require(magrittr)
require(tidyverse)
dat <- structure(list(p1 = c(0.0854261831077604, 0.408418657218253,
0.577793646477315, 0.578028229977424, 0.48933166218204, 0.53117814324334,
0.526653494462464, 0.00687616283435221, 0.444300425796509, 0.00287319455358522,
0.949821402532831, 0.96832469523368, 0.953281969982759, 0.360125244759434,
0.407921095422844, 0.885776732104954, 0.159882184516691, 0.911094990767761,
0.0444367172734037, 0.144888951725151, 0.508858686640707, 0.694913731085945,
0.117270366119258, 0.78227546070467, 0.980457304886186, 0.711464034564424,
0.753944466390685, 0.0474210438747038, 0.00344183466223558, 0.0290017465534545,
0.75092385236303, 0.868873921257987, 0.744396990487425, 0.0140007244233847,
0.0332266395043963, 0.482897084793009, 0.0535516646483004, 0.452926358923891,
0.0144057727301603, 0.171918034525543), p2 = c(0.101262675229211,
0.196913109208586, 0.37814311161382, 0.0677625689405156, 0.12517090579686,
0.409083554335168, 0.158886941347288, 0.847394861862651, 0.180560031076741,
0.967122694294885, 0.000901627067665116, 0.00039495110143705,
9.70707318411806e-05, 0.546200038486894, 0.435475454787648, 5.95555269800323e-06,
0.0178837768834925, 8.42690065415846e-06, 0.00777059697751842,
0.0020397073541544, 0.486699073016371, 0.283679673247571, 0.857183359146641,
0.200712003853458, 0.0164911141652784, …Run Code Online (Sandbox Code Playgroud) 我想知道我当前的库中有多少个软件包是从GitHub安装的,但是找不到解决方法
# The number of installed packages in my library
length(.packages(all.available=TRUE))
[1] 145
Run Code Online (Sandbox Code Playgroud)
这篇R-bloggers帖子显示了软件包的版本,但未显示从https://www.r-bloggers.com/list-of-user-installed-r-packages-and-their-versions/安装的位置。
ip <- as.data.frame(installed.packages()[, c(1, 3:4)])
rownames(ip) <- NULL
ip <- ip[is.na(ip$Priority), 1:2, drop=FALSE]
print(ip, row.names=FALSE)
Package Version
abind 1.4-5
acepack 1.4.1
ade4 1.7-10
albersusa 0.3.0
AnnotationDbi 1.40.0
ansistrings 1.0.0
ape 5.0
aqp 1.15
ash 1.0-15
assertthat 0.2.0
astsa 1.8
ATmet 1.2
automap 1.0-14
backports 1.1.2
base64 2.0
base64enc 0.1-3
bazar 1.0.6
BBmisc 1.11
beeswarm 0.2.3
BH 1.66.0-1
Run Code Online (Sandbox Code Playgroud)
我以为我可以加载所有软件包,然后运行devtools::session_info()以查找我想要的东西
https://www.r-bloggers.com/loading-all-installed-r-packages/
lapply(.packages(all.available=TRUE),
function(x) library(x, …Run Code Online (Sandbox Code Playgroud) 我想要:
期望的输出将是
到目前为止我失败的尝试.预先感谢您的任何帮助!
library(ggplot2)
set.seed(1337)
dat <- structure(list(id = structure(c(2L, 2L, 2L, 2L),
.Label = c("1.1", "1.2", "1.3", "2.1", "2.2", "2.3"),
class = "factor"),
value = c(3.1, 3.1, 3.1, 3.1),
x = c(2.2, 1.1, 1.2, 2.5),
y = c(0.5, 1, 2.1, 1.7)),
class = "data.frame",
row.names = c(NA, -4L))
line <- data.frame(
x = cumsum(runif(50, max = 0.1)),
y = cumsum(runif(50, max = 0.1))
)
ggplot(dat, aes(x = x, y = y)) +
geom_polygon(aes(color = "Border", group = …Run Code Online (Sandbox Code Playgroud) 我想从以下字符串中提取州名缩写(2个字母)和邮政编码(4或5个数字)
address <- "19800 Eagle River Road, Eagle River AK 99577
907-481-1670
230 Colonial Promenade Pkwy, Alabaster AL 35007
205-620-0360
360 Connecticut Avenue, Norwalk CT 06854
860-409-0404
2080 S Lincoln, Jerome ID 83338
208-324-4333
20175 Civic Center Dr, Augusta ME 4330
207-623-8223
830 Harvest Ln, Williston VT 5495
802-878-5233
"
Run Code Online (Sandbox Code Playgroud)
对于邮政编码,我尝试了一些我在这里找到的方法,但它不起作用主要是因为5号街道地址或邮政编码只有4个数字
text <- readLines(textConnection(address))
library(stringi)
zip <- stri_extract_last_regex(text, "\\d{5}")
zip
library(qdapRegex)
rm_zip3 <- rm_(pattern="(?<!\\d)\\d{5}(?!\\d)", extract = TRUE)
zip <- rm_zip3(text)
zip
[1] "99577" "1670" "35007" "0360" "06854" "0404" "83338" "4333" …Run Code Online (Sandbox Code Playgroud) 我有以下路径
filePath <- "/data/folder1/subfolder1/foo.dat"
Run Code Online (Sandbox Code Playgroud)
我想知道subfolder1哪个位于哪里foo.dat.我看到了其他语言的解决方案,但在R中没有找到一个.最简单的方法是什么?谢谢!
我尝试了什么
> basename(filePath)
[1] "foo.dat"
> dirname(filePath)
[1] "/data/folder1/subfolder1"
Run Code Online (Sandbox Code Playgroud)