psych

R Loop To New Data Frame Summary Weighted

泄露秘密 提交于 2019-12-11 10:36:16
问题 I have a tall data frame as such: data = data.frame("id"=c(1,2,3,4,5,6,7,8,9,10), "group"=c(1,1,2,1,2,2,2,2,1,2), "type"=c(1,1,2,3,2,2,3,3,3,1), "score1"=c(sample(1:4,10,r=T)), "score2"=c(sample(1:4,10,r=T)), "score3"=c(sample(1:4,10,r=T)), "score4"=c(sample(1:4,10,r=T)), "score5"=c(sample(1:4,10,r=T)), "weight1"=c(173,109,136,189,186,146,173,102,178,174), "weight2"=c(147,187,125,126,120,165,142,129,144,197), "weight3"=c(103,192,102,159,128,179,195,193,135,145), "weight4"=c(114,182,199,101

Why are there differences in psych::principal between “Varimax” and “varimax”?

百般思念 提交于 2019-12-11 03:16:37
问题 In a related question, I have asked why there are differences between stats::varimax and GPArotation::Varimax , both of which psych::principal calls, depending on the option set for rotate = . The differences between these two (see other question) account for some, but not all of the differences from psych::principal . It appears that these differences somehow get exacerbated by psych::principal . (I have a simple theory why, and I'd like to get that confirmed). library(GPArotation) library

How do I deserialize classes in Psych?

痴心易碎 提交于 2019-12-10 17:53:36
问题 How do I deserialize in Psych to return an existing object, such as a class object? To do serialization of a class, I can do require "psych" class Class yaml_tag 'class' def encode_with coder coder.represent_scalar 'class', name end end yaml_string = Psych.dump(String) # => "--- !<class> String\n...\n" but if I try doing Psych.load on that, I get an anonymous class, rather than the String class. The normal deserialization method is Object#init_with(coder) , but that only changes the state of

Install packages does not work: Permission denied

时光毁灭记忆、已成空白 提交于 2019-12-08 03:33:16
问题 I'm struggling to install the package "psych". I started to use the command install.packages("psych") . The download started and the result was the following: Installing package into ‘C:/Users/Username/Documents/R/win-library/3.5’ (as ‘lib’ is unspecified) also installing the dependency ‘mnormt’ trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/mnormt_1.5-5.zip' Content type 'application/zip' length 373388 bytes (364 KB) downloaded 364 KB trying URL 'https://cran.rstudio.com/bin

Rails 3 - 'Couldn't parse Yaml'

半世苍凉 提交于 2019-12-07 02:05:57
问题 I don't know what I did wrong. I try to run 'rails c,' but it just gives me an error. It was working 10 minutes ago. :\ C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 2 column 12 (Psych::SyntaxError) from C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream' from C:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse' from C:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/applic ation/configuration

Install packages does not work: Permission denied

北慕城南 提交于 2019-12-06 18:25:26
I'm struggling to install the package "psych". I started to use the command install.packages("psych") . The download started and the result was the following: Installing package into ‘C:/Users/Username/Documents/R/win-library/3.5’ (as ‘lib’ is unspecified) also installing the dependency ‘mnormt’ trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/mnormt_1.5-5.zip' Content type 'application/zip' length 373388 bytes (364 KB) downloaded 364 KB trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/psych_1.8.4.zip' Content type 'application/zip' length 5741178 bytes (5.5 MB)

why does psych yaml interpreter add line breaks around 80 characters?

送分小仙女□ 提交于 2019-12-05 13:54:37
问题 Psych is the default yaml engine since ruby 1.9.3 Why, oh why does psych add a line break in its output? Check the example below. ruby -v # => ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux] require 'yaml' "this absolutely normal sentence is more than eighty characters long because it IS".to_yaml # => "--- this absolutely normal sentence is more than eighty characters long because it\n IS\n...\n" YAML::ENGINE.yamler = 'syck' "this absolutely normal sentence is more than eighty

Clean install OSX 10.9.1 returns “undefined method `path2class'” when trying to install gems

点点圈 提交于 2019-12-04 17:13:28
问题 I just installed a clean Mavericks installation with Homebrew and RVM. Both brew doctor and rvm requirements return "all good", however, when I run bundle install in my project dir most of my gems install fine, but a handful fail to install with the same following error: Bundler::GemspecError: Could not read gem at /Users/NK/.rvm/gems/ruby-2.0.0-p353/cache/eventmachine-1.0.3.gem. It may be corrupted. An error occurred while installing eventmachine (1.0.3), and Bundler cannot continue. Make

Ruby - LoadError enc/trans/single_byte

一笑奈何 提交于 2019-12-01 05:21:43
I encountered a weird problem while using ActiveRecord::Store module in my Ruby on Rails app. As I understand, this module use 'serialize' method under the hood so it just serialize your data to yaml format with ruby built-in psych gem. It works OK most of the time, but sometimes I get 500 error with the following message: LoadError (cannot load such file -- enc/trans/single_byte): ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:27:in `write' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:27:in `end_document' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1

YAML::load raises undefined class/module error

不羁的心 提交于 2019-12-01 03:27:31
I’m implementing paper trail like feature in my rails app. In order to do this, I’m serializing object in YAML. I’ve got item_at_version method, which basically does YAML::load(cached_object) – this works pretty well, however, I have no idea why, sometimes it returns undefined class/module _class name_ . It works with models like Event, Conversation, Note, and many more, but without any reason, it seems to throw that error for models like Dataset, Comment, Student (I’ve tried to find any pattern for that, without any luck). I’m using rails 3.2.8, ruby 1.9.3p327, psych as YAML Engine (Psych: