Dear all,
For treatment contrasts I would :
library(car)
data(Prestige)
attach(Prestige)
levels(type)
contrasts(type) <-contr.treatment(levels(type),base =2 )
Alternatively to change my level I would do :-
type = relevel(type,ref="prof")
Now I want the sigma constraint.
For this the LAST level (
try:
n.questions <- 10 # or however many you want
mult.choice <- 2
scores <- rbinom(1000, size = n.questions, prob = 1/mult.choice)
On Sat, Jun 18, 2016 at 3:12 PM, Naresh Gurbuxani <
naresh_gurbux...@hotmail.com> wrote:
> I want to calculate a function many times over. My solution below work
On 18/06/2016 6:12 PM, Naresh Gurbuxani wrote:
I want to calculate a function many times over. My solution below works, but
does not seem very elegant.
# my function to run many times over
stud.score <- function(n.questions, mult.choice = 2) {
prob.success <- 1 / mult.choice
an
Don't use HTML on sending email- messes up the data.
What do you mean that you get lots of duplicates? If you have duplicated
entries in df2 this will lead to dups because of the way merge works (here
is the help file):
If there is more than one match, all possible matches contribute
one r
use replicate:
> stud.score <- function(n.questions, mult.choice = 2) {
+ prob.success <- 1 / mult.choice
+ answers <- (runif(n.questions) < prob.success)
+ return(sum(answers))
+ }
>
> # create 1000 results
> result <- replicate(1000, stud.score(10))
>
> # look at hist
Hi Humberto,
The "0 row" error usually arises from a calculation in which a
non-existent object is used. I see that you have created a vector with
the name "lens" and that may be where this is happening. Have a look
at:
length(lens)
or if it is not too long, just:
lens
If it is zero length, tha
6 matches
Mail list logo