Different font faces and sizes within label text entries in ggplot2

I am building charts that have two lines in the axis text. The first line contains the group name, the second line contains that group population. I build my axis labels as a single character string with the format "LINE1 n LINE2". Is it possible to assign different font faces and sizes to LINE1 and LINE2, even though they are contained within a single character string? I would like

ggplot2中标签文本条目中不同的字体和大小

我正在构建轴文本中有两行的图表。 第一行包含组名,第二行包含该组人口。 我使用格式“LINE1 n LINE2”将我的轴标签构建为单个字符串。 是否可以为LINE1和LINE2分配不同的字体大小和大小,即使它们包含在单个字符串中? 我想让LINE1变大变粗,而LINE2变小变大。 以下是一些示例代码: Treatment <- rep(c('T','C'),each=2) Gender <- rep(c('Male','Female'),2) Response <- sample(1:100,4) test_df <- data.

Assign polygon duplicate area (overlap) to only one polygon

I have a shapefile (which can be downloaded here http://www.car.gov.br/publico/municipios/downloads?sigla=MA (any would do)) where each polygon represent a rural private property, as the owner submited it. However, the polygons overlap. For the analysis I need to run, an area cannot be accounted twice (ie. be in two properties ). So, on the areas that do overlap, I wanted to assign this duplic

将多边形重复区域(重叠)分配给仅一个多边形

我有一个shapefile(可以在这里下载http://www.car.gov.br/publico/municipios/downloads?sigla=MA(任何会这样做)),其中每个多边形代表一个农村私有财产,因为所有者提交它。 但是,多边形重叠。 对于我需要运行的分析,一个区域不能被计入两次(即在两个属性中)。 因此,在重叠的区域,我想将这个重复区域分配给面积最小的多边形,并从另一个区域中擦除。 我看过其他问题,比如这个 。 但没有人真的这样做。 你可

buffer areas around lines ggplot2

I would like a chart that as a function of the day in the year, advances from 0 -> 100% in both x and y axes (where each axis is a separate metric). Depending on where the data is relative to the day in the year, I'd like to show whether that's good or bad. Quite simply, I can show it like this: So the above plot shows we're in a good sitaution because the "tip" (dark

线ggplot2周围的缓冲区

我想要一张图表,作为一年中某一天的函数,在x和y轴(每个轴都是一个单独的度量标准)中,从0 - > 100%前进。 根据数据相对于一年中的某一天的情况,我想说明这是好还是不好。 很简单,我可以像这样展示它: 所以上面的图表显示我们处于良好的状态,因为“小费”(最黑暗的最大分数)超过了50%的标准(并且假设我们在一年中是50%)。 但我想在水平线和垂直线周围添加渐变线以显示更多细微差别。 下面是对这些区域的解

modelr: Fitting multiple models with resampled data

In the tidy model of data science (TM) implemented in modelr , resampled data are organized using list-columns: library(modelr) library(tidyverse) # create the k-folds df_heights_resampled = heights %>% crossv_kfold(k = 10, id = "Resample ID") It is possible to map a model to each of the training datasets in the list-column train and to compute a performance metric by map ping onto the l

modelr:用重采样数据拟合多个模型

在实施数据科学(TM)的整齐模型modelr ,重新采样数据使用列表列组织: library(modelr) library(tidyverse) # create the k-folds df_heights_resampled = heights %>% crossv_kfold(k = 10, id = "Resample ID") 它可以map模型,以列表中的每个列的训练数据集的train ,并通过计算性能度量map平榜上有名列test 。 如果需要使用多个模型来完成,则需要对每个模型重复此操作。 # create a list of formulas formula

R function for position of sun giving unexpected results

I'd like to calculate the position of the sun given time, latitude, and longitude. I found this great question and answer here: Position of the sun given time of day, latitude and longitude. However, when I evaluate the function I get incorrect results. Given the quality of the answer, I'm almost certain there's something wrong on my end, but I'm asking this question as a recor

R功能为阳光的位置提供意想不到的结果

我想计算太阳给定时间,纬度和经度的位置。 我在这里发现了这个伟大的问题和答案:太阳在一天中的时间,纬度和经度的位置。 但是,当我评估函数时,我得到不正确的结果。 鉴于答案的质量,我几乎可以肯定,我的问题出现了问题,但我把这个问题作为试图解决问题的记录。 为便于说明,以下是重印后功能的代码: astronomersAlmanacTime <- function(x) { # Astronomer's almanach time is the number of # days since

Efficiently construct GRanges/IRanges from Rle vector

I have a Run length encoded vector representing some value at every position on the genome, in order. As a toy example suppose I had just one chromosome of length 10, then I would have a vector looking like library(GenomicRanges) set.seed(1) toyData = Rle(sample(1:3,10,replace=TRUE)) I would like to coerce this into a GRanges object. The best I can come up with is gr = GRanges('toyChr',IRan

从Rle载体高效构建GRanges / IRanges

我有一个运行长度编码的向量,代表基因组上每个位置的某个值。 作为一个玩具的例子,假设我只有一个长度为10的染色体,那么我会看到一个向量 library(GenomicRanges) set.seed(1) toyData = Rle(sample(1:3,10,replace=TRUE)) 我想将它强制为一个GRanges对象。 我能拿出最好的是 gr = GRanges('toyChr',IRanges(cumsum(c(0,runLength(toyData)[-nrun(toyData)])), width=runLength(toyData))

defined functions in R?

I am supposed to write a function for Stirling Numbers of the Second Kind, given by the formula: For this, I have written the following function in R: stirling <- function(n, k) { sum = 0 for (i in 0:k) { sum = sum + (-1)^(k - i) * choose(k, i) * i^n } sum = sum / factorial(k) return(sum) } The next part of the question is to "create a plot for n = 20, k = 1,2,...,10&q

R中定义的函数?

我应该为公式给出的第二类斯特林数的函数: 为此,我在R中编写了以下函数: stirling <- function(n, k) { sum = 0 for (i in 0:k) { sum = sum + (-1)^(k - i) * choose(k, i) * i^n } sum = sum / factorial(k) return(sum) } 问题的下一部分是“为n = 20,k = 1,2,...,10创建一个情节”。 我做了一些研究,我认为方法curve或plot可能会对我有所帮助。 然而,我猜这些方法是在y的形式为f(x) (即一个

LSTM example to time series prediction via MXNet in R

Does anybody know where can I find an example of LSTM via MXNet (R package)? The basic task is prediction of x[t + 1] value by x[1 ... t] sequence. 如果你仍然在寻找它,那么有这个非常好的博客解释如何在mxnet中使用R绑定来使用RNN:https://www.r-bloggers.com/recurrent-models-and-examples-with-mxnetr/。

通过RNet中的MXNet进行时间序列预测的LSTM实例

有谁知道我在哪里可以通过MXNet(R软件包)找到LSTM的例子? 基本任务是通过x [1 ... t]序列预测x [t + 1]值。 如果你仍然在寻找它,那么有这个非常好的博客解释如何在mxnet中使用R绑定来使用RNN:https://www.r-bloggers.com/recurrent-models-and-examples-with-mxnetr/。

R, determine shortest path

I have a graph and need the shortest distance between all nodes. Now I made the following function, shortestPath <- function(streets, length) { streets <- matrix(streets, byrow=TRUE, ncol=2) # from -> to g <- graph.data.frame(as.data.frame(streets)) # create graph, see plot(g) return <- shortest.paths(g, weights = length) # return routes lengths } Here str

R,确定最短路径

我有一个图形,需要所有节点之间的最短距离。 现在我做了以下功能, shortestPath <- function(streets, length) { streets <- matrix(streets, byrow=TRUE, ncol=2) # from -> to g <- graph.data.frame(as.data.frame(streets)) # create graph, see plot(g) return <- shortest.paths(g, weights = length) # return routes lengths } 这里的streets是一个包含数据的向量,我们有一

R package does not load dependencies

This question already has an answer here: How can I load dependencies in an R package? 2 answers Since there's no answer yet... J_F writes Have you tried to put the three packages under "Depends" in your DESCRIPTON? I ran into this recently and Depends still seems to work where Imports does not.

R软件包不加载依赖关系

这个问题在这里已经有了答案: 我如何加载R包中的依赖关系? 2个答案 由于目前还没有答案...... J_F写道 您是否试图将三个软件包放在您的DESCRIPTON的“Depends”下? 我最近遇到了这种情况, Depends似乎仍然适用于Imports没有的地方。