[R] ifelse and wildcard matching

2009-12-06 Thread Jennifer Brea
Hi, I'm trying to create a new variable using the following code: A$B2<-ifelse(A$B %in% "EDUCATION","EDUCATION",NA) The problem is, I want the new variable to be labeled "EDUCATION" if the original *contains* "EDUCATION", not of it is an exact match. I've done a lot of searching on wild card

[R] Zelig, oprobit error

2009-05-04 Thread Jennifer Brea
Hello, I'm getting an error message when I use the ordered probit model "oprobit" in the zelig function. Using the same form as in the help file, we get an error message. It produces coefficients, but no standard errors. See results below. Any hints? Thanks! > > o.probit <- zelig(as.fa

Re: [R] function returns R object with name based on input

2009-04-26 Thread Jennifer Brea
0.4370229 1.5752294 1.5675705 David Winsemius wrote: On Apr 24, 2009, at 11:56 AM, Jennifer Brea wrote: I wanted to ask how I can make a for loop or a function return an R object with a unique name based on either some XX of the for loop or some input for the function. For example if I have

[R] function returns R object with name based on input

2009-04-24 Thread Jennifer Brea
I wanted to ask how I can make a for loop or a function return an R object with a unique name based on either some XX of the for loop or some input for the function. For example if I have a function: fn<-function(data,year){ which does does some stuff } How do I return an object from the fu

[R] Converting a dataframe to a matrix

2009-03-10 Thread Jennifer Brea
If I have a dataframe which is organized like this: name color likes? 1 sally red0 2 sally blue1 3 sally green1 4 jake red0 5 jake blue1 6 jake green1 7 tom red1 8 tom blue0 9 tom green0 And I want to create a matrix in the form: red