similar to: How to generate a conditional dummy in R?

Displaying 20 results from an estimated 400 matches similar to: "How to generate a conditional dummy in R?"

2018 May 29
0
How to generate a conditional dummy in R?
Hi Faradj, What a problem! I think I have worked it out, but only because the result is the one you said you wanted. # the sample data frame is named fkdf Y2Xby3<-function(x) { nrows<-dim(x)[1] X<-rep(0,nrows) for(i in 1:(nrows-2)) { if(!is.na(x$Y[i])) { if(x$Y[i] == 1 && any(is.na(x$Y[(i+1):(i+2)]))) X[i]<-1 if(i > 1) { if(X[i-1] == 1) X[i]<-0 } }
2018 May 29
1
How to generate a conditional dummy in R?
Dear Jim, wow! It worked! Thanks a lot. I did as you suggested and it worked well with the real data. Although it gave me this error: Error in if (!is.na(x$Y[i])) { : argument is of length zero. For some reason the X1 produced less observations than it is in the data. But it's not a big deal - I identified those cases and simply deleted from the data (it was countries that only appeared
2018 May 16
1
Systemfit Question
I can't get my simultaneous equations to work using system fit. Please help. #Reproducible script Empdata<- read.csv("/Users/ngwinuiazenui/Documents/UPLOADemp.csv") View(Empdata) str(Empdata) Empdata$gnipc<-as.numeric(Empdata$gnipc) install.packages("systemfit") library("systemfit") pdata <- plm.data(Empdata,
2018 May 15
2
Systemfit
OK, Let's try this again! Here is the reproducible script; it is long because I had to copy the panel dataset here. My question is related to systemfit; I don't know how to get the result for the entire panel. #Reproducible script Empdata<- read.csv("/Users/ngwinuiazenui/Documents/UPLOADemp.csv") View(Empdata) install.packages("systemfit")
2018 May 16
0
Systemfit
Sadly you failed to set your email program to send plain text and the data is corrupted at my end. I also think you need to reduce the size of the data set... the intent here is to increase your understanding, not debug your particular analysis. I will say that I am having a very challenging time understanding what you are trying to accomplish though. What are the equations that you think need
2018 May 15
0
Systemfit
... and the mailing list is picky about attachments... whatever you attached did not conform to the stringent requirements mentioned in the Posting Guide. Pasting the code right into the email is usually safest, though you DO have to post using plain text (as the Posting Guide indicates) or your code may get mangled by the automatic html format removal. On May 15, 2018 7:04:31 AM PDT, Bert Gunter
2018 May 15
1
Systemfit
Unless there is good reason not to, always cc the list -- there are lots of smarter folks than I on it who can help. I may or may not have time to look at this. Hopefully someone else will. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip
2009 Mar 07
2
piecewise linear regression
Hi - I'd like to construct and plot the percents by year in a small data set (d) that has values between 1988 and 2007. I'd like to have a breakpoint (buy no discontinuity) at 1996. Is there a better way to do this than in the code below? > d year percent se 1 1988 30.6 0.32 2 1989 31.5 0.31 3 1990 30.9 0.30 4 1991 30.6 0.28 5 1992 29.3 0.25 6 1994 30.3
2011 Jan 17
1
filling in datasets of differing lengths
g''day all, I need help with this please. I have a dataset of site names and years they were trapped in (a subset of it is bs, below) and a dataset of sites that actually caught animals (subsetted as brep, below). I need to add to brep, a row with a zero in the classcount column, for every year each site was trapped but caught nothing. so for Site 1, I need to add rows that say
2012 Sep 04
3
Comparing Von Bertalanffy Growth Curves
I am trying to compare Vbert growth curves from several years of fish data. I am following the code provided by: http://www.ncfaculty.net/dogle/fishR/gnrlex/VonBertalanffy/VonBertalanffy.pdf. Specifically the section on VBGM Comparisons between groups. ? This code is pretty cut and dry. I am able to run it perfectly with the "fake" data that is provided. But when I run it with my own
2012 Sep 10
0
More help need on Von Bertalanffy Growth Curves
Howdy, Last week I got some great help on why I was getting an error code when trying to run this model, thanks everyone!  I was able to get the code up and running beautifully for several data sets.  Now I am getting different errors with this new data set.  I can't figure out why, I have more data points with this species, and it is ordered exactly the same as the other species I have been
2012 Sep 02
3
Loading Chess Data
All, What would be the most efficient way to load the data at the following address into a dataframe? http://ratings.fide.com/top.phtml?list=men Thanks, David -- View this message in context: http://r.789695.n4.nabble.com/Loading-Chess-Data-tp4642006.html Sent from the R help mailing list archive at Nabble.com.
2012 Jul 10
2
estimation of NA by predict command
Dear arun and all R users, I will first of all try to simply define my issue.. I have data in the following format Year Discharge dd/mm/yyyy x .. … … … There are some NA values in the discharge which I would like to predict by using “predict command”. I cant figure out the way to write the coding for that. Could you please help me on that??? I have also ,written
2012 Oct 30
2
help with for loop: new column giving count of observation for each SITEID
Hello, I think this is easy, but I can't seem to find a good way to do this in the R help. I have a list of sites, with multiple years of data for each site id. I want to create a new column that gives a number describing whether it is the 1st year ("1" ) the data was collected for the site, the second year ("2"), etc. I have different years for each siteid, but I don't
2010 Jul 22
4
Drop firms in unbalanced panel if not more than 5 observations in consecutive years for all variables
Dear R-user, a few weeks ago I consulted the list-serve with a similar question. However, my task changed a little but sufficiently to get lost again. So I would appreciate any help on the following issue. I use the plm package and work with firm-level data in a panel. I would like to eliminate all firms that do not fulfill the requirement of having an observation in every variable used for at
2011 Feb 14
5
Transforming relational data
Hi, I have a large dataset with info on individuals (B) that have been involved in projects (A) during multiple years (C). The dataset contains three columns: A, B, C. Example: A B C 1 1 a 1999 2 1 b 1999 3 1 c 1999 4 1 d 1999 5 2 c 2001 6 2 d 2001 7 3 a 2004 8 3 c 2004 9 3 d 2004 I am interested in how well all the individuals in a project know each other. To
2017 Oct 19
1
looping using 'diverse' package measures
Hi everyone, I'm new at R (although I'm a Stata user for some time and somehow proficient in it) and I'm trying to use the 'diverse' R package to compute a few diversity measures on a sample of firms for a period of about 10 years. I was wondering if you can give me some hints on how to best proceed on using the 'diverse' package. My sample has the following setup.
2010 Feb 28
1
ggplot 'annotate problem' again.
I had a problem annotating a graph last year ( see http://n4.nabble.com/Putting-names-on-a-ggplot-td907158.html#a907158 for the discussion) Stefan (smu) provided a solution using annotate(). However I apparently did not update the graph file and,now, when I go back to the thread and try to use Stefan's solution it does not seem to work although I am sure that it did then. The problem
2010 Jun 30
6
Multiline and grouping in R
Hi All, this is my first mail here. I'm trying to plot a multiline chart grouping values with no success. I have read a lot in the official Wiki and also searched via Google, but I did not find anything. I'm importing some data from a cvs file. Here is a sample: YEAR,AREA,CASES 1988,CONTRACTS,286 1988,INTERNATIONAL,189 1988,FAMILY,385 1988,TAXATION,177 1989,CONTRACTS,233
2010 Nov 20
2
plotting a timeline
I was trying to recreate this kind of timeline plot: http://www.vertex42.com/ExcelArticles/create-a-timeline.html As you can see in their excel example, the events are nicely placed out on both sides of the timeline axis. AFAIK there is no function to do this nicely in R-project. Furthermore, graphics and lattice packages are unable to draw the x-axis in the middle of the plot. (datapoints