similar to: Function to modify existing data.frame

Displaying 20 results from an estimated 40000 matches similar to: "Function to modify existing data.frame"

2005 Jan 19
1
Function to modify existing data.frame--Improving R Language
Thanks to everyone who replied to my question! A comment regarding Thomas's point below: Java & other object-oriented languages that are function rather than macro based usually provide methods & other capabilities that allow pass by reference in certain cases and these methods would solve the problem I posed regarding how to change values in an existing data.frame from within a
2003 Jul 13
3
How robust is mle in R?
A newbie question: I'm trying to decide whether to run a maximum likelihood estimation in R or Stata and am wondering if the R mle routine is reasonably robust. I'm fairly certain that, with this data, in Stata I would get a lot of complaints about non-concave functions and unproductive steps attempted, but would eventually have a successful ML estimate. I believe that, with the
2003 Jul 24
4
Problem w/ source
I'm trying to use the source command to run commands from a file. For instance: source("do.R"), where do.R is a file in the same directory in which I am running R. The contents of do.R are: ls() print("hello") sum(y1) mean(y1) After source("do.R"), all I see is: > source("do.R") [1] "hello" I'm using the X11 version of R for
2009 Jul 11
0
foreign generates bad Stata data files (PR#13820)
Full_Name: peter muhlberger Version: 2.7.1 OS: Ubuntu x86_64 dual core Submission from: (NULL) (70.238.206.13) I've spent half a day generating .dta files using write.dta only to have them crash my copy of Stata. I eventually discovered that removing a string variable with a maximum observed length of 280 characters allows Stata to read the file without problems. A Stata limit is that the
2009 Oct 28
3
variable labels to accompany data.frame
Often it is useful to keep a "codebook" to document the contents of a dataset. (By "dataset" I mean a rectangular structure such as a dataframe.) The codebook has as many rows as the dataset has columns (variables, fields). The columns (fields) of the codebook may include: ? variable name ? type (character, factor, integer, etc) ? variable label
2006 Jan 05
2
Wald tests and Huberized variances (was: A comment about R:)
On Wed, 4 Jan 2006, Peter Muhlberger wrote: One comment in advance: please use a more meaningful subject. I would have missed this mail if a colleague hadn't pointed me to it. > I'm someone who from time to time comes to R to do applied stats for social > science research. [snip] > I would also prefer not to have to work through a > couple books on R or S+ to learn how to
2009 Jun 29
2
Large Stata file Import in R
Hi I am using Stata 10 and I need to import a data set in stata 10 to R, I have saved the dataset in lower versions of Stata as well by using saveold command in Stata. My RAM is 4gb and the stata file is 600MB, I am getting an error message which says : "Error: cannot allocate vector of size 3.4 Mb In addition: There were 50 or more warnings (use warnings() to see the first 50)" Thus
2011 Mar 10
2
tobit regression model
Hi, I'm trying to fit a tobit regression model to some data. When fitting the exact same data in Stata, I have no problems at all, however R won't converge. Its not a maxiters thing, since I've tried increasing this already. I need to be able to fit the model in R since there are users of the code that don't have a Stata license. The code is: require(AER) left = 3.218476 x =
2013 Oct 15
1
cluster option in stata for random intercept model in the R language?
Dear R-list, I am currently working on a dataset with a colleague who uses stata. We fit a random intercept model to the data (decisions clustered in participants) and get closely the same results in stata (using xtreg re) and R (using the lme4 or multilevel package). Now in stata, there is an additional option for the regression to control for clustering; the vce(cluster clustvar) option,
2004 May 10
1
Explaining Survival difference between Stata and R
Dear Everybody: I'm doing my usual "how does that work in R" thing with some Stata projects. I find a gross gap between the Stata and R in Cox PH models, and I hope you can give me some pointers about what goes wrong. I'm getting signals from R/Survival that the model just can't be estimated, but Stata spits out numbers just fine. I wonder if I should specify initial
2013 Nov 20
1
Binomial GLM in Stata and R
Hello, I'm not a Stata user so I'm trying to reproduce Stata results that are given to me in R. I would like to use a GLM with a complementary log-log function. The stata code I have is: glm c IndA fia, family(binomial s) link(cloglog) offset(offset) The R code is: glmt <- glm(data=dataset, c ~ IndA + fia, offset = offset, family = binomial(link = cloglog)) Which yields
2009 Dec 28
2
WHO Anthro growth curve macros and R
Hi all, I've got a project where I have to calculate weight-for-age Z-scores, preferably using the WHO standards. WHO have been very nice to publish macros for doing this in both STATA,SPSS, SAS and Splus formats (see http://www.who.int/childgrowth/software/en/), but for some reason have chosen not to use the free R alternative to Splus. In the Splus zipfile there are nine datafiles with a
2012 Jul 08
2
Notation for previous observation in a data frame
I've created a data frame in R, but in order to clean up some of the data, I need to set certain variable observations equal to the value of their previous observation (it would be conditional, but that part's less important right now). In Stata, I would simply set var = var[_n-1] in those cases. What is the R equivalent? [[alternative HTML version deleted]]
2009 Jan 20
2
Summing Select Columns of a Data Frame?
Hi, I would like to operate on certain columns in a dataframe, but not others. My data looks like this: x1 x2 x3 1 2 3 4 5 6 7 8 9 I want to create a new column named x4 that is the sum of x1 and x2, but NOT x3. I looked at colSums and apply, but those functions seem to use all the columns in a dataframe. How do I only use select columns? If it helps, in Stata this would be gen x4
2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi R-users! Being new to R, and a fairly advanced Stata-user, I guess part of my problem is that my mindset (and probably my language as well) is wrong. Anyway, I have what I guess is a rather simple problem, that I now without success spent days trying to solve. I have a bunch of datasets imported from Stata that is labelled aa_2000 aa_2001 aa_2002, etc. Each dataset is imported as a matrix, and
2007 Jan 30
2
R and S-Plus got the different results of principal component analysis from SAS, why?
Dear Rusers, I have met a difficult problem on explaining the differences of principal component analysis(PCA) between R,S-PLUS and SAS/STATA/SPSS, which wasn't met before. Althought they have got the same eigenvalues, their coeffiecients were different. First, I list my results from R,S-PLUS and SAS/STATA/SPSS, and then show the original dataset, hoping sb. to try and explain it.
2013 Jan 16
1
Read.dta and Write.dta Binary Data Error
Thanks in advance. I pass data sets between R and Stata and think dta files would be the best files for this. To do this I can use package foreign or package memisc. I mostly use foreign, although have used memisc and this problem mostly didn't happen, but created errors at other times. I have a csv data set (and created a test case) with with at least one column completely missing. This
2008 Aug 22
1
filtering out data
Greetings, Apologies for such a simple question, but I have been trying to figure this out for a few days now (I'm quite new to R), have read manuals, list posts, etc., and not finding precisely what I need. I am accustomed to working in Stata, but I am currently working through the multilevel package right now. In Stata, I would include the statement "if model1 == 1" at the end
2011 Mar 28
1
maximum likelihood accuracy - comparison with Stata
Hi everyone, I am looking to do some manual maximum likelihood estimation in R. I have done a lot of work in Stata and so I have been using output comparisons to get a handle on what is happening. I estimated a simple linear model in R with lm() and also my own maximum likelihood program. I then compared the output with Stata. Two things jumped out at me. Firstly, in Stata my coefficient
2013 Oct 02
1
foreign package problem with stata 13
foreign package does not support dataset saved at stata 13. anyone knows any wayt to make it works? [[alternative HTML version deleted]]