我确信我忽略了一些显而易见的东西,但我想kable用自定义css 制作我的桌子.
你可以在这里找到我RMD和CSS文件的要点 .
我的目标是利用我在这里找到的一些表CSS示例.
当我运行我的报告时,我的表看起来像这样:

但是从上面的CSS示例中,它应该如下图所示.

我的问题:我错过了什么,或者这种风格水平是不可能的RMarkdown.
我的RMD文件也显示如下:
---
title: "Test Table CSS"
output:
html_document:
theme: NULL
style: flat-table.css
---
I want to be able to style my tables with CSS. From the looks of it, I should be able to do that
through the use of `CSS` and `knitr:kable`.
```{r setup, echo=FALSE}
data(mtcars)
mt_head = head(mtcars[, 1:5])
```
I want to be able to …Run Code Online (Sandbox Code Playgroud) 我想将我的ts对象转换为data.frame对象.我的MWE如下:
set.seed(12345)
dat <- ts(data=runif(n=10, min=50, max=100), frequency = 4, start = c(1959, 2))
library(reshape2)
df <- data.frame(date=as.Date(index(dat)), Y = melt(dat)$value)
Run Code Online (Sandbox Code Playgroud)
date Y
1 1975-05-14 86.04519
2 1975-05-14 93.78866
3 1975-05-14 88.04912
4 1975-05-15 94.30623
5 1975-05-15 72.82405
6 1975-05-15 58.31859
7 1975-05-15 66.25477
8 1975-05-16 75.46122
9 1975-05-16 86.38526
10 1975-05-16 99.48685
Run Code Online (Sandbox Code Playgroud)
我在日期栏中丢失了我的宿舍.如果您能帮助解决问题,我将非常感谢.提前致谢.
每当我尝试在Ubuntu 14.04上安装R中的任何软件包时,我都会收到以下错误:
Error in readRDS(file) : error reading from connection
Run Code Online (Sandbox Code Playgroud)
我正在尝试与之交互ggplot2.我的代码如下:
library(ggplot2)
p <- qplot(as.factor(dose), len, data=ToothGrowth, geom = "boxplot", color = supp) + theme_bw()
p <- p + labs(x="Dose", y="Response")
p <- p + stat_summary(fun.y = mean, geom = "point", color = "blue")
p <- p + stat_summary(fun.y = mean, geom = "line", aes(group = 1))
p <- p + opts(axis.title.x = theme_text(size = 12, hjust = 0.54, vjust = 0))
p <- p + opts(axis.title.y = theme_text(size = 12, angle = 90, vjust = 0.25))
print(p) …Run Code Online (Sandbox Code Playgroud) 我无法在单个站点PCA因子图上添加分组变量省略号,其中还包括PCA可变因子箭头.
我的代码:
prin_comp<-rda(data[,2:9], scale=TRUE)
pca_scores<-scores(prin_comp)
#sites=individual site PC1 & PC2 scores, Waterbody=Row Grouping Variable.
#site scores in the PCA plot are stratified by Waterbody type.
plot(pca_scores$sites[,1],
pca_scores$sites[,2],
pch=21,
bg=point_colors[data$Waterbody],
xlim=c(-2,2),
ylim=c(-2,2),
xlab=x_axis_text,
ylab=y_axis_text)
#species=column PCA1 & PCA2 Response variables
arrows(0,0,pca_scores$species[,1],pca_scores$species[,2],lwd=1,length=0.2)
#I want to draw 'Waterbody' Grouping Variable ellipses that encompass completely,
# their appropriate individual site scores (this is to visualise total error/variance).
Run Code Online (Sandbox Code Playgroud)
我试图使用dataellipse,plotellipses和ellipse函数,但无济于事.无知就是赢得了这一点.如果我没有提供足够的信息,请告诉我.
数据(log10转换):
dput(data)
structure(list(Waterbody = structure(c(4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, …Run Code Online (Sandbox Code Playgroud) 我想基于因子列添加一列均值R data.frame.像这样:
df1 <- data.frame(X = rep(x = LETTERS[1:2], each = 3), Y = 1:6)
df2 <- aggregate(data = df1, Y ~ X, FUN = mean)
df3 <- merge(x = df1, y = df2, by = "X", suffixes = c(".Old",".New"))
df3
# X Y.Old Y.New
# 1 A 1 2
# 2 A 2 2
# 3 A 3 2
# 4 B 4 5
# 5 B 5 5
# 6 B 6 5
Run Code Online (Sandbox Code Playgroud)
要完成这个问题,我要创建两个不必要的data.frames.我想知道一种方法,可以通过因子列将一列方法附加到我的原始列中 …
我想知道如何在线上获取数据标签以获得ggplot2轮廓.谢谢
require(grDevices) # for colours
x <- seq(-4*pi, 4*pi, len = 27)
y <- seq(-4*pi, 4*pi, len = 27)
r <- sqrt(outer(x^2, y^2, "+"))
rx <- range(x <- 10*1:nrow(volcano))
ry <- range(y <- 10*1:ncol(volcano))
ry <- ry + c(-1, 1) * (diff(rx) - diff(ry))/2
plot(
x = 0
, y = 0
, type = "n"
, xlim = rx
, ylim = ry
, xlab = ""
, ylab = ""
)
contour(
x = x
, …Run Code Online (Sandbox Code Playgroud) 我可以使用以下代码制作美国州级失业率图表.
library(XML)
library(ggplot2)
library(plyr)
library(maps)
unemp <-
readHTMLTable('http://www.bls.gov/web/laus/laumstrk.htm',
colClasses = c('character', 'character', 'numeric'))[[2]]
names(unemp) <- c('rank', 'region', 'rate')
unemp$region <- tolower(unemp$region)
us_state_map <- map_data('state')
map_data <- merge(unemp, us_state_map, by = 'region')
map_data <- arrange(map_data, order)
states <- data.frame(state.center, state.abb)
p1 <- ggplot(data = map_data, aes(x = long, y = lat, group = group))
p1 <- p1 + geom_polygon(aes(fill = cut_number(rate, 5)))
p1 <- p1 + geom_path(colour = 'gray', linestyle = 2)
p1 <- p1 + scale_fill_brewer('Unemployment Rate (Jan 2011)', palette …Run Code Online (Sandbox Code Playgroud) 我正试图通过使用cowplot包来以出版物的方式安排绘图.
我只是希望面板的尺寸和尺寸相同.
library(ggplot2)
library(cowplot)
gg1 <- ggplot(mtcars)+
geom_point(aes(x=mpg,y=hp))+
theme_bw()+
theme(aspect.ratio=1)
gg2 <- ggplot(mtcars)+
geom_point(aes(x=mpg,y=hp,fill=cyl))+
facet_wrap(~cyl,ncol=2)+
theme_bw()+
theme(aspect.ratio=1,
legend.position='none')
output <- plot_grid(gg1,gg2, labels = c('A','B'),label_size = 20)
print(output)
Run Code Online (Sandbox Code Playgroud)
如您所见,水平轴既不匹配,也不匹配面板的上边缘.
这个论点align从cowplot不方位图工作.
有任何想法吗?
随着acf我们可以ACF plot在基地R图.
x <- lh
acf(x)
Run Code Online (Sandbox Code Playgroud)

下面的代码可以用来获取ACF plot在ggplot2.
conf.level <- 0.95
ciline <- qnorm((1 - conf.level)/2)/sqrt(length(x))
bacf <- acf(x, plot = FALSE)
bacfdf <- with(bacf, data.frame(lag, acf))
library(ggplot2)
q <- ggplot(data=bacfdf, mapping=aes(x=lag, y=acf)) +
geom_bar(stat = "identity", position = "identity")
q
Run Code Online (Sandbox Code Playgroud)

题
如何获得线而不是条形或如何设置条的宽度,使它们看起来像线条?谢谢