Re: [R] stripping #s in a text file prior to reading into table or dataframe

2010-10-27 Thread Donald Braman
? -- Donald Braman http://ssrn.com/author=286206 http://www.culturalcognition.net/braman/ http://www.law.gwu.edu/Faculty/profile.aspx?id=10123 Henrique Dallazuanna Tue, 26 Oct 2010 09:11:33 -0700 Try this: read.table('don.5.clusters.txt', header = TRUE, comment.char = '', quote = '') On Tue, Oct 26

Re: [R] stripping #s in a text file prior to reading into table or dataframe

2010-10-27 Thread Donald Braman
read.delim2 did the trick -- many thanks!!! On Wed, Oct 27, 2010 at 10:01 AM, Jorge Ivan Velez jorgeivanve...@gmail.com wrote: ?read.delim2 HTH, Jorge On Wed, Oct 27, 2010 at 9:51 AM, Donald Braman dbra...@law.gwu.eduwrote: Thanks for your advice! I still get the same error, though

[R] stripping #s in a text file prior to reading into table or dataframe

2010-10-26 Thread Donald Braman
I'm importing a lot of text tables of data (from Latent Gold) that includes hashes in some of the column names (Cluster#1, Cluster#2, etc.). Is there an easy way to strip the offending hashes out before pushing the text into a table or data frame? I thought I'd use gsub, e.g., but can't figure

Re: [R] stripping #s in a text file prior to reading into table or dataframe

2010-10-26 Thread Donald Braman
, 2010 at 10:49 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 26/10/2010 10:33 AM, Donald Braman wrote: I'm importing a lot of text tables of data (from Latent Gold) that includes hashes in some of the column names (Cluster#1, Cluster#2, etc.). Is there an easy way to strip the offending

[R] dirichlet models

2010-09-05 Thread Donald Braman
Does anyone know of a package (or workaround) for fitting a dirichlet distribution by maximum likelihood? (I'm looking for something like this: http://repec.org/bocode/d/dirifit.html, that allows for both dependent variables summing to 1 predictive variables of any sort.) Don -- Donald

[R] latent class analysis with mixed variable types

2010-07-23 Thread Donald Braman
As an alternative to Latent GOLD, I'm wondering if anyone knows of and R package that can manage Latent Class Analysis with mixed variable types (continuous, ordinal, and nominal/binary). [[alternative HTML version deleted]] __

Re: [R] repeating values in levels()

2009-10-19 Thread Donald Braman
Thanks! I've figured out how to fix it, but how I got here is still a puzzle. :-) Cheers, Don On Sat, Oct 17, 2009 at 5:36 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Donald Braman wrote: Can someone help me understand this results? levels(as.factor(miset1$facts_convict)) [1] 1 1 2 3

[R] repeating values in levels()

2009-10-17 Thread Donald Braman
Can someone help me understand this results? levels(as.factor(miset1$facts_convict)) [1] 1 1 2 3 4 5 6 converting to numeric and back doesn't seem to help: levels(as.factor(as.numeric(miset1$facts_convict))) [1] 1 1 2 3 4 5 6 It's messing up my ologits.  Any way to correct this?

[R] standard error associated with correlation coefficient

2009-08-27 Thread Donald Braman
I want the standard error associated with a correlation. I can calculate using cor var, but am wondering if there are libraries that already provide this function. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] simple graph question: manipulating variable names

2009-08-25 Thread Donald Braman
- paste(iv, dv, .png, sep = ) png(file=graphname, width=300, height=300) plot(dv ~ iv, pch=.) lines(loess.smooth(iv, dv), lty=1) dev.off() } } Clearly that doesn't work. I'm not sure how to make R see the iv and dv strings as variables. Advice? Donald Braman phone: 413-628-1221 http

[R] lowess puzzle

2009-08-06 Thread Donald Braman
I was trying to fit a curve to the number of people who identify as liberal by age. I got some puzzling results which suggested to me that I don't really understand how local polynomial fitting works. Why, I am wondering, is lowess producing a local fit of zero for every age? liberal.bin [1]

[R] lowess puzzle

2009-08-06 Thread Donald Braman
I am trying to fit a curve to the number of people who identify as liberal by age. I got some puzzling results which suggested to me that I don't really understand how local polynomial fitting works. Why, I am wondering, is lowess producing a local fit of zero for every age? liberal [1] 0 0 0

Re: [R] lowess puzzle

2009-08-06 Thread Donald Braman
Resolved. It works if I set iter=0. On Thu, Aug 6, 2009 at 9:03 PM, Donald Braman dbra...@law.gwu.edu wrote: I was trying to fit a curve to the number of people who identify as liberal by age. I got some puzzling results which suggested to me that I don't really understand how local

[R] recoding strings containing colons

2009-07-08 Thread Donald Braman
Curious to know if recode can work with strings containing colons. I haven't gotten it to work yet, but perhaps there is a way? Donald Braman http://www.culturalcognition.com/braman/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

[R] mapping states with colors

2009-07-02 Thread Donald Braman
', param=50, region = c(syg, dtr), fill=TRUE, col=c('red', 'blue')) Obviously that doesn't work. A couple questions: 1. How do I get Alaska Hawaii on the map? 2. How to I set the col atttribute for a subset of the states I'm mapping? Many thanks in advance for any help! Don Donald Braman

[R] newbie query: simple crosstabs

2009-04-07 Thread Donald Braman
I've been playing around with various table tools, trying to construct a fairly simple cross-tab. It shouldn't be hard, but for some reason it turning out to be (for me). If I want to see how many men and how many women agree with a agree/disagree question (coded 1,0), I can do this:

Re: [R] newbie query: simple crosstabs

2009-04-07 Thread Donald Braman
Thanks for the help everyone! I'm new to vectors, and don't quite get it. This works for me: binary.vars - c(q1, q2, q3, ...) apply(mydata[binary.vars], 2, tapply, mydata[male], mean) but this doesn't: other.vars - c(male, race, religion) apply(mydata[other.binary.vars], 2, tapply,

[R] inverting a table

2009-04-05 Thread Donald Braman
Is there an easy way to invert a table? (not to solve for the inverted matrix, just swap rows for columns vice versa). I've gone through my data manipulation bible (Phil Spector's book), but to no avail. [[alternative HTML version deleted]]

[R] quantile / centile

2008-09-27 Thread Donald Braman
I'm wondering if there is a simple way to assign a quantile to a vector in a data frame, much like one could in Stata using centile. Let's say I want 100 slices in my assignation. I can easily see what the limits of each slice by using quantile: quantile(my.df$my.var, probs=seq(0, 1, 0.01)) But

Re: [R] quantile / centile

2008-09-27 Thread Donald Braman
Dallazuanna [EMAIL PROTECTED]wrote: Try this: my.df$my.newvar - quantile(my.df$my.var, probs = seq(0.01,1, 0.01)) On Sat, Sep 27, 2008 at 3:50 AM, Donald Braman [EMAIL PROTECTED] wrote: I'm wondering if there is a simple way to assign a quantile to a vector in a data frame, much like one could

[R] sem testing multiple hypotheses with BIC

2008-07-15 Thread Donald Braman
I'm coming from the AMOS world and am wondering if there is a simple way to do multiple hypothesis testing in the manner of BIC analyses in AMOS using the sem package in R. I've read the documentation, but don't see anything in there except for basic BIC scores. Perhaps someone has devised a

[R] two newbie questions

2008-06-22 Thread Donald Braman
around all the ways to ditch looping in R. Donald Braman http://www.law.gwu.edu/Faculty/profile.aspx?id=10123 http://research.yale.edu/culturalcognition http://ssrn.com/author=286206 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] two newbie questions

2008-06-22 Thread Donald Braman
), add=TRUE, col=black) curve (cbind (1, 0, x, 0*x) %*% coef(my.fit), add=TRUE, col=gray) dev.off() } )) On Sun, Jun 22, 2008 at 6:26 PM, Donald Braman [EMAIL PROTECTED] wrote: # I've tried to make this easy to paste into R, though it's probably so simple you won't need to. # I have

[R] imputationlist, update, and recode

2008-05-29 Thread Donald Braman
I'm stumbling my way through manipulating data in multiply imputed datasets, and have run into a problem translating code I used to run on my pre-imputed dataset to multiple datasets. The imputation runs just fine, as does the reading of the mi data sets into an imputationList. I run into

[R] manipulating multiply imputed data sets

2008-05-28 Thread Donald Braman
and when it creates a new one. I suppose I could do this in Python and the use PyR, but I'd really like to learn a bit more about how R syntax. Any help on this specific problem or general advice on manipulating data in multiply imputed datasets in R would be much appreciated. -- Donald Braman http

[R] recoding data with loops

2008-05-19 Thread Donald Braman
# I'm new to R and am trying to get the hang of how it handles # dataframes loops. If anyone can help me with some simple tasks, # I'd be much obliged. # First, i'd like to generate some random data in a dataframe # to efficiently illustrate what I'm up to. # let's say I have six variables as

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Donald Braman Sent: Monday, May 19, 2008 12:42 PM To: r-help@r-project.org Subject: [R] recoding data with loops # I'm new to R and am trying to get the hang of how it handles # dataframes loops. If anyone can help me

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
Many thanks -- You are right; I had rnorm() and sample() mixed up in my code. I'll work on generating a normal ordinal sample next. Cheers, Don On Mon, May 19, 2008 at 4:07 PM, Erik Iverson [EMAIL PROTECTED] wrote: Hello - Donald Braman wrote: # I'm new to R and am trying to get the hang

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
(reverse_me_varnames)) {mdf$reversed_varnames[i] - recode(mdf$reverse_me_varnames[i], '5:7=NA; 1=4; 2=3; 3=2; 4=1;', as.factor.result=FALSE) While I don't get an error message, the data don't change. Any advice on reverse coding non-continguous variables? On Mon, May 19, 2008 at 4:12 PM, Donald Braman

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
not allow 'computed' indices. I hope this helps! Erik Donald Braman wrote: Erik, Your example was just what I needed to generate the data -- many, many thanks! The names() function was something I had not grasped fully. I now have this and it works very nicely: var_list - c(HEQUAL