有没有办法在tidyLPA中设置ylim?

时间:2019-08-20 20:44:10

标签: r

TidyLPA显示我的配置文件非常接近,因为该图包括4sd处的一些数据,这些数据不是特别相关。我需要关闭轮廓,以便更好地区分它们,我想这可以像使用ylim一样在其他图中完成。 我可以在其他图中设置ylim = c(-2,2),但不能在tidyLPA中设置。有什么想法吗?

df14sdips %>%
+ estimate_profiles(3) %>%
+ plot_profiles(ylim(c(2,-2)))
df14sdips %>%
+ estimate_profiles(3) %>%
+ plot_profiles() %>%
+ ylim = c(-2,2)

我希望将潜在轮廓分析图的y轴限制为2sd,以便可以更好地可视化轮廓。

样本数据-6个测试中的 30个条目(.txt):

"Maths LOVS"    "Maths Cito"    "Vocabulary LOVS"   "Reading LOVS"  "Language Cito" "StudySkills Cito"
"1" 0.0671429326375007  1.06391342455154    -1.08388039914369   -0.816179736326985  0.25173862392771    0.517265154353926
"2" -1.12597344846514   0.505551882271436   -0.617399002616901  -0.0936445452475341 0.467918743647645   0.863546370410494
"3" 0.120339518761401   0.539906264698047   -1.73064169926657   -0.16733347384839   0.502273126074255   0.735456263581255
"4" -0.23903065167119   -0.304811612163194  -0.278746590553686  0.0670640778022095  0.380288694719723   0.375236081866138
"5" -0.616382072080422  0.829738362032626   -0.322127523646096  -1.20658478854632   0.108062809830955   1.20729321240926
"6" -1.05638810370839   0.378673529842578   -0.395291601431218  -0.537500172155185  0.921466371810001   0.68903997564221
"7" 0.197205046990417   1.29801892403265    -1.03461552377744   -1.57723969366673   0.225212238189229   0.89141900823188
"8" 0.410678352345201   1.63878176065714    -0.991809117940375  -1.01191989462087   -0.258453740044383  0.212722639603278
"9" 0.286240693862018   0.902271136984276   -0.641390318960871  -0.352337815303102  0.28421201776927    -0.478995714351591
"10"    -0.405733436792271  0.775313406727944   -0.193130682257497  -0.642678193863461  0.425240166391235   0.0409887397940498
"11"    0.557908919234021   1.75170738084235    -1.6071888331962    -0.944545589582956  -0.363626845879404  0.605744968582188
"12"    -0.275936614196619  0.859746482057899   -1.17635036238632   0.138201426304247   0.116008948880089   0.338330119340708
"13"    0.827367601944659   0.843512425456673   -0.854655826391371  0.0295470576455958  -0.750558030825914  -0.0952132278296429
"14"    -0.941375571307427  0.0880070497841929  -0.538251964340366  -0.129838175823515  1.13159248396757    0.389866177719545
"15"    -0.708721149924812  0.483948766666165   -0.146566729723096  -0.594289901872797  0.496202780900443   0.469426233954097
"16"    -0.975014456852698  -0.175271934632946  1.03978115528315    -0.320837142231226  3.39150395194588    0.0398384264878348
"17"    -1.05157381100508   0.545082300519202   -3.372332465639128  -0.155004779423627  0.178380009229804   0.855448746318834
"18"    -0.125534258383198  0.755569775331894   -1.11496311219107   0.341213971927773   0.1448646497756 -0.0011510264609994
"19"    -0.423731204930964  -0.0517852962947251 0.560554253292851   -0.770130738733248  4.664652048858308   0.0204409378077781
"20"    -0.108827026140084  0.63392867574321    -0.847646296356465  0.466905492334106   -0.161617073927934  0.0172562283471669
"21"    4.390870755775603   2.09213452493676    -1.45018348579508   -0.898320062393696  -0.243219491440494  0.108717758916913
"22"    0.0649434157211933  0.368279430950211   -0.762890960113354  0.153069568868156   -0.336767070298771  0.513365614872566
"23"    -0.774530069404755  0.222240422509287   4.799989661620209   -0.0372030729572412 -0.21097807259087   0.000481130823370091
"24"    0.91794864548949    0.0331364945687819  -0.280145903839457  -0.473639620892763  -0.518406420835466  0.321106805509415
"25"    -0.231997063653461  1.63086118348102    -2.05490646213536   -0.225138638061037  0.583958605884264   0.297222374484574
"26"    -0.173624574383766  0.499956961583629   -0.500239783035331  0.2405134661171 0.142529727588207   -0.209135797869839
"27"    -0.531762508998681  1.19218313379532    0.191986389176359   -1.17410492670681   0.00105202764781032 0.320645885086002
"28"    -0.356407487700386  1.57562492534999    0.134022115059063   -0.890236105813171  0.0148125709727817  -0.477816017868278
"29"    -0.370237847403355  0.302779416055362   0.523323395376514   -0.39015500528386   -0.468783289004379  0.403073330259718
"30"    -0.32387957325217   -0.424529752956463  -0.264653430059215  0.494715150749882   0.310457706784524   0.207889898733443

1 个答案:

答案 0 :(得分:0)

plot_profiles的输出是一个ggplot对象。因此,您可以使用ylim设置y轴范围。

library(dplyr)
library(tidyLPA)
library(ggplot2)
p <- df14sdips %>%
 estimate_profiles(3) %>%
 plot_profiles() 
p + ylim(c(-2,2))

enter image description here

df14sdips %>%
  estimate_profiles(3) %>%
  plot_profiles() + ylim(c(-2,2))