繁体   English   中英

事实帮助以及如何使用公式进行编码

[英]factanal help and how to code using formula

我有这个方程式适用于R

fit <- factanal (f[filename : x+n], factors , rotation='varimax')

我该放在哪里? 我知道将文件名放在显示的地方,但是我是从excel表中获取数据的,该表是有关城市郊区以及郊区的不同质量的,我已将其上传到了

您应该看一下?factanal以了解每个函数参数的含义。

例如,

  1. 第一个参数x必须是数字matrix或可以强制转换为数字matrix的对象(例如data.frame )。
  2. 第二个自变量factors指定因子分析中因子的数量。

这是一个基于一些随机生成的数据的示例。

# Sample data
set.seed(2017)
df <- data.frame(
    a = runif(10),
    b = runif(10),
    c = runif(10),
    d = runif(10),
    e = runif(10))

# Perform factor analysis
fit <- factanal(df, factors = 2, rotation = 'varimax')
#
#Call:
#factanal(x = df, factors = 2, rotation = "varimax")
#
#Uniquenesses:
#    a     b     c     d     e
#0.162 0.639 0.005 0.397 0.054
#
#Loadings:
#  Factor1 Factor2
#a          0.914
#b  0.601
#c -0.990   0.120
#d          0.777
#e  0.820   0.523
#
#               Factor1 Factor2
#SS loadings      2.017   1.727
#Proportion Var   0.403   0.345
#Cumulative Var   0.403   0.749
#
#Test of the hypothesis that 2 factors are sufficient.
#The chi square statistic is 1.14 on 1 degree of freedom.
#The p-value is 0.285

我不知道如何从Excel工作表中读取数据(它是XLS / XLSX还是CSV文件?),但是您需要确保factanal的第一个参数是数字matrixdata.frame

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM