我正在尝试将Excel创建的.csv文件读入R,其中所有向量(CSV文件中的列)都是数字.但是,每次导入它们时它们都会转换为因子.
以下是我的CSV的示例:

这是我的代码:
options(StringsAsFactors=F)
data<-read.csv("in.csv",dec=",",sep=";")
Run Code Online (Sandbox Code Playgroud)
如你所见,我负责将de dec设置为","并将sep设置为";".但是,所有应该是数字的向量都是因子!
有人可以给我一些建议吗?谢谢!
所以我的散点图的一些标签重叠。我曾尝试将 direct.label 与方法“smart.grid”一起使用,但它不会产生适当的结果。这是我目前的图表:
生成它的代码:
ggplot(d, aes(x=ILE2, y=TE,label=d$CA)) +
geom_point(mapping=aes(x=ILE2, y=TE, fill=d$CA), size=9, shape=20, color="black") +
geom_text(data = d,mapping=aes(x=ILE2, y=TE,label=d$CA), size=4, vjust=3, hjust=0.5,size=6)+
geom_smooth(method=lm,se=F)+
theme(legend.position = "none")+
ggtitle("Tasa de Empleo según Índice de Libertad Económica") +
labs(x="Índice de Libertad Económica",y="Tasa de Empleo") +
theme(plot.title = element_text(family =windowsFonts(Times=windowsFont("TT Times New Roman")), color="#666666", face="bold", size=22, hjust=0.5)) +
theme(axis.title = element_text(family =windowsFonts(Times=windowsFont("TT Times New Roman")), color="#666666", face="bold", size=22))
Run Code Online (Sandbox Code Playgroud)
数据:
structure(list(CA = structure(c(1L, 2L, 3L, 4L, 6L, 8L, 9L, 5L,
7L, 10L, 11L, 12L, 14L, …Run Code Online (Sandbox Code Playgroud) 所以我想在数据框列的名称中使用单词之间的空格,并将数据框打印为乳胶格式的 pdf。但是,当我xtable()这样做时,列的名称会被连接起来。
例如,我希望第二列的标题看起来像“Categoria de Referencia”。相反,我得到的是:
有人知道如何解决这个问题吗?这是将数据帧转换为乳胶的 R 块:
tab<-xtable(dat,caption="Efectos de las Variables sobre la Probabilidad de Conversión",digits=2)
print(tab,latex.environments = "center",include.rownames=FALSE)
Run Code Online (Sandbox Code Playgroud)
这是生成数据框的代码:
structure(list(Variable = structure(c(4L, 3L, 3L, 3L, 3L, 3L,
2L, 1L), .Label = c("App", "Clicker", "País", "Uso"), class = "factor"),
Categoría.de.Referencia = structure(c(3L, 1L, 1L, 1L, 1L,
1L, 2L, 4L), .Label = c("Brasil", "Clicker", "No Acaba Unidad",
"No Usa App"), class = "factor"), Categoría.Considerada = structure(c(1L,
2L, 3L, 4L, 5L, 7L, 6L, 8L), .Label = c("Acaba la Unidad", …Run Code Online (Sandbox Code Playgroud) 为了从熊猫中获取单个单元格,使用哪种方法更好(在性能和可靠性方面)DataFrame:get_value() 或 loc[]?