简体   繁体   English

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

[英]factanal help and how to code using formula

I've got this equation to apply in R 我有这个方程式适用于R

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

what do i put where? 我该放在哪里? i know to put my filename where it says, but i'm getting my data from an excel table that i've made about suburbs in my city and different qualities about the suburbs and i've uploaded that to r 我知道将文件名放在显示的地方,但是我是从excel表中获取数据的,该表是有关城市郊区以及郊区的不同质量的,我已将其上传到了

You should take a look at ?factanal to understand the meaning of every function argument. 您应该看一下?factanal以了解每个函数参数的含义。

For example, 例如,

  1. the first argument x needs to be a numeric matrix or an object that can be coerced to a numeric matrix (like a data.frame ). 第一个参数x必须是数字matrix或可以强制转换为数字matrix的对象(例如data.frame )。
  2. the second argument factors specifies the number of factors in the factor analysis. 第二个自变量factors指定因子分析中因子的数量。

Here is a example based on some randomly generated data. 这是一个基于一些随机生成的数据的示例。

# 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

I don't know how you read in data from an Excel sheet (is it an XLS/XLSX or CSV file?), but you need to ensure that the first argument in factanal is a numeric matrix or data.frame . 我不知道如何从Excel工作表中读取数据(它是XLS / XLSX还是CSV文件?),但是您需要确保factanal的第一个参数是数字matrixdata.frame

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

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