Skip to content

Instantly share code, notes, and snippets.

View tbates's full-sized avatar
🙈

Tim Bates tbates

🙈
View GitHub Profile
@tbates
tbates / lavaan_version.R
Created October 2, 2012 15:09
SEM model in lavaan
require(lavaan)
bifactor <- "
general.factor =~ Easy_Reservation + Preferred_Seats + Flight_Options + Ticket_Prices
+ Seat_Comfort + Seat_Roominess + Overhead_Storage
+ Clean_Aircraft + Courtesy + Friendliness + Helpfulness + Service
ticketing =~ Easy_Reservation + Preferred_Seats + Flight_Options + Ticket_Prices
aircraft =~ Seat_Comfort + Seat_Roominess + Overhead_Storage + Clean_Aircraft
service =~ Courtesy + Friendliness + Helpfulness + Service"
@tbates
tbates / coin.flip.R
Created September 27, 2012 21:51
Turned coins
n = 1000;
coins = rep(0, n)
for (i in 2:n) {
whatToFlip = seq(from = i, to = n, by = i)
coins[whatToFlip] = coins[whatToFlip] + 1
}
sqrt(which(!as.logical(coins%%2)))
# [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31