我正在尝试在下面创建的ggplot2中显示颜色渐变。因此,使用以下数据和代码
vector <- c(9, 10, 6, 5, 5)
Names <- c("Leadership", "Management\n", "Problem Solving",
"Decision Making\n", "Social Skills")
# add \n
Names[seq(2, length(Names), 2)] <- paste0("\n" ,Names[seq(2, length(Names), 2)])
# data.frame, including a grouping vector
d <- data.frame(Names, vector, group=c(rep("Intra-capacity", 3), rep("Inter-capacity", 2)))
# correct order
d$Names <- factor(d$Names, levels= unique(d$Names))
d$group_f = factor(d$group, levels=c('Intra-capacity','Inter-capacity'))
# plot the bars
p <- ggplot(d, aes(x= Names, y= vector, group= group, fill=vector, order=vector)) +
geom_bar(stat= "identity") +
theme_bw()+
scale_fill_gradient(low="white",high="blue")
# use …Run Code Online (Sandbox Code Playgroud) 所以我正在使用这个数据框:
xym <- data.frame(
Var1 = c("vloga", "odlo?itve", "dolgoro?no",
"krizno", "uživa v", "vloga", "odlo?itve",
"dolgoro?no", "krizno", "uživa v", "vloga",
"odlo?itve","dolgoro?no", "krizno", "uživa v",
"vloga","odlo?itve", "dolgoro?no", "krizno",
"uživa v"),
Var2 = c("Nad","Nad", "Nad", "Nad", "Nad", "Pod",
"Pod", "Pod", "Pod", "Pod", "Enak","Enak",
"Enak", "Enak", "Enak", "Sam.", "Sam.", "Sam.",
"Sam.", "Sam."),
value = c(4, 3, 4, 4, 3, 3, 3, 2, 3, 3, 3, 2.5, 2.5,
2, 3.5 ,5 ,6 ,6 ,5 ,6))
Run Code Online (Sandbox Code Playgroud)
并使用此代码:
p <- ggplot(xym, aes(x = Var1, y = value, …Run Code Online (Sandbox Code Playgroud) 所以我有数据框
dput(df)
structure(list(Frequency = structure(c(1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L), .Label = c("2", "3", "4", "5"), class = "factor"), Prcentage = c(1,
33, 58, 8, 2, 40, 53, 5), label = list("Insufficient", "Average",
"Good", "Excellent", "Insufficient", "Average", "Good", "Excellent"),
name = c("implementation", "implementation", "implementation",
"implementation", "energy", "energy", "energy", "energy")), .Names = c("Frequency",
"Prcentage", "label", "name"), row.names = c(NA, 8L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
并使用以下代码
# Get the levels for type in the required order
df$label = factor(df$label, levels = …Run Code Online (Sandbox Code Playgroud) 我现在正在学习R Studio,我只是想知道如何导入具有多张纸(8张)的xlsx文件。
到目前为止。.我有:
library(readxl)
(filename) <- read_excel("(file location).xlsx")
view(filename)
Run Code Online (Sandbox Code Playgroud)
它只打印出excel文件的第一张纸,但是如果将它们全部打印出来,我将不胜感激。
另外,使用CSV文件或xlsx更好吗?
多谢你们。