r

Combine and merge legends in ggplot2 with patchwork

瘦欲@ 提交于 2021-02-09 19:28:48
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried

Combine and merge legends in ggplot2 with patchwork

醉酒当歌 提交于 2021-02-09 19:25:18
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried

Using read.csv with a symlinked file

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-09 15:50:09
问题 What I Am Trying To Do My source file is very large and I want to avoid copying it into other folders. I decided to create a symlink to the large file and want to use read.csv to read in the file. Folder structure project1/data/source-file.csv project2/data/alias-to-source-file.csv What Went Wrong Reading in the source file works perfectly, but when I try to read in the symlink, I get the following error: line 1 appears to contain embedded nulls . I know that I can just duplicate the file and

How to combine two data frames using dplyr or other packages?

拈花ヽ惹草 提交于 2021-02-09 15:45:48
问题 I have two data frames: df1 = data.frame(index=c(0,3,4),n1=c(1,2,3)) df1 # index n1 # 1 0 1 # 2 3 2 # 3 4 3 df2 = data.frame(index=c(1,2,3),n2=c(4,5,6)) df2 # index n2 # 1 1 4 # 2 2 5 # 3 3 6 I want to join these to: index n 1 0 1 2 1 4 3 2 5 4 3 8 (index 3 in two df, so add 2 and 6 in each df) 5 4 3 6 5 0 (index 5 not exists in either df, so set 0) 7 6 0 (index 6 not exists in either df, so set 0) The given data frames are just part of large dataset. Can I do it using dplyr or other packages

How to combine two data frames using dplyr or other packages?

耗尽温柔 提交于 2021-02-09 15:40:13
问题 I have two data frames: df1 = data.frame(index=c(0,3,4),n1=c(1,2,3)) df1 # index n1 # 1 0 1 # 2 3 2 # 3 4 3 df2 = data.frame(index=c(1,2,3),n2=c(4,5,6)) df2 # index n2 # 1 1 4 # 2 2 5 # 3 3 6 I want to join these to: index n 1 0 1 2 1 4 3 2 5 4 3 8 (index 3 in two df, so add 2 and 6 in each df) 5 4 3 6 5 0 (index 5 not exists in either df, so set 0) 7 6 0 (index 6 not exists in either df, so set 0) The given data frames are just part of large dataset. Can I do it using dplyr or other packages

How to combine two data frames using dplyr or other packages?

こ雲淡風輕ζ 提交于 2021-02-09 15:38:04
问题 I have two data frames: df1 = data.frame(index=c(0,3,4),n1=c(1,2,3)) df1 # index n1 # 1 0 1 # 2 3 2 # 3 4 3 df2 = data.frame(index=c(1,2,3),n2=c(4,5,6)) df2 # index n2 # 1 1 4 # 2 2 5 # 3 3 6 I want to join these to: index n 1 0 1 2 1 4 3 2 5 4 3 8 (index 3 in two df, so add 2 and 6 in each df) 5 4 3 6 5 0 (index 5 not exists in either df, so set 0) 7 6 0 (index 6 not exists in either df, so set 0) The given data frames are just part of large dataset. Can I do it using dplyr or other packages

Unexpected error message while joining data.table with rbindlist() using mget()

非 Y 不嫁゛ 提交于 2021-02-09 15:22:15
问题 While preparing this answer, I've got the error message Error: value for ‘spine_hlfs’ not found from running setDT(giraffe)[rbindlist(mget(df_names), idcol = "df.name"), on = "runkey", project := df.name][] while df_list <- mget(df_names) setDT(giraffe)[rbindlist(df_list, idcol = "df.name"), on = "runkey", project := df.name][] works as expected. Before reporting an issue on github, I want to verify with the community that this indeed is a bug or if there is a simple explanation for the error

Unexpected error message while joining data.table with rbindlist() using mget()

☆樱花仙子☆ 提交于 2021-02-09 15:16:44
问题 While preparing this answer, I've got the error message Error: value for ‘spine_hlfs’ not found from running setDT(giraffe)[rbindlist(mget(df_names), idcol = "df.name"), on = "runkey", project := df.name][] while df_list <- mget(df_names) setDT(giraffe)[rbindlist(df_list, idcol = "df.name"), on = "runkey", project := df.name][] works as expected. Before reporting an issue on github, I want to verify with the community that this indeed is a bug or if there is a simple explanation for the error

Unexpected error message while joining data.table with rbindlist() using mget()

房东的猫 提交于 2021-02-09 15:14:20
问题 While preparing this answer, I've got the error message Error: value for ‘spine_hlfs’ not found from running setDT(giraffe)[rbindlist(mget(df_names), idcol = "df.name"), on = "runkey", project := df.name][] while df_list <- mget(df_names) setDT(giraffe)[rbindlist(df_list, idcol = "df.name"), on = "runkey", project := df.name][] works as expected. Before reporting an issue on github, I want to verify with the community that this indeed is a bug or if there is a simple explanation for the error

Unexpected error message while joining data.table with rbindlist() using mget()

╄→гoц情女王★ 提交于 2021-02-09 15:14:19
问题 While preparing this answer, I've got the error message Error: value for ‘spine_hlfs’ not found from running setDT(giraffe)[rbindlist(mget(df_names), idcol = "df.name"), on = "runkey", project := df.name][] while df_list <- mget(df_names) setDT(giraffe)[rbindlist(df_list, idcol = "df.name"), on = "runkey", project := df.name][] works as expected. Before reporting an issue on github, I want to verify with the community that this indeed is a bug or if there is a simple explanation for the error