我正在尝试制作一个条形图,其中最大的条形图离y轴最近,最短的条形图最远。所以这有点像我的桌子
Name Position
1 James Goalkeeper
2 Frank Goalkeeper
3 Jean Defense
4 Steve Defense
5 John Defense
6 Tim Striker
因此,我正在尝试构建一个条形图,根据位置显示玩家的数量
p <- ggplot(theTable, aes(x = Position)) + geom_bar(binwidth = 1)
但图中显示的是守门员杆,然后是防
我有一个像这样的线性回归:
lmGeneexp = lm(gene_expression ~ (pos1 + pos2 + pos3), data = donor_snp_sample)
summary(lmGeneexp)
当我运行这段代码时,结果如下:
Coefficients: (2 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.708 64.905 0.088 0.930
pos11
我被一个显然非常简单的因子字符变量的问题所困扰。
test = data.frame(uv=c("03834","06044","06054","03834","48557","48207","03834","06044","48557"))
test
uv=c()
for (i in 1:length(test$uv)){
uv[i]=test[i,"uv"]
}
uv
这就是我得到的:
> test = data.fram
我是R的新手,但我正在取得很好的进步。除了一件事之外,我已经能够按照自己的意愿修改ggplot2 :分类标签在我的箱线图中沿着x轴绘制的顺序。我认为这只是我在如何在公式中处理数据帧范围的知识上的一个漏洞,但这里是假数据,作为一个称为df的数据帧:
Index Label Value
index1 A 1
index2 A 2
index3 A 3
index4 B 12
index5 B 11
index6 B 10
index7 C 8
index8
我在R中创建了箱形图,但是,它们显示不正确。我的数据基于Kaggle上的德国信用数据集。
我的代码有两个不同的属性,试图被测试:
data %>%
ggplot(aes(x = Creditability, y = Purpose, fill = Creditability)) +
geom_boxplot() +
ggtitle("Creditability vs Purpose")
data %>%
ggplot(aes(x = Creditability, y = Account.Balance, fill = Creditability
在使用rpart()和predict()命令生成预测模型后,我应该在R中使用什么命令来执行混淆矩阵?
# Grow tree
library(rpart)
fit <- rpart(activity ~ ., method="class", data=train.data)
printcp(fit) # display the results
plotcp(fit) # visualize cross-validation results
summary(fit) # detailed summary of splits
# Prune the tree (in my
我有一个数据帧df,看起来像这样。 Color Rejection
Red 0
Orange 0
Yellow 1
Green 1
Blue 1 我想运行一个对数回归,其中“蓝色”是0,1可以是红色、橙色、黄色或绿色。 我的对数回归设置如下所示。 glm(
formula = Rejection ~ Color,
data = df,
family = binomial(link="logit")
) 在回归分析中,如何设置“蓝色”为默认值,而其他颜色为x变量的"1“?
我在R中的雷达图出了点小问题,尽管图很好,但我得到了以下警告:
> source('~/.active-rstudio-document')
Warning message:
In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated
> radar
Warning messages:
1: In `levels<-`(`*tmp*`, value