Re: [R] Data manipulation problem

2010-04-09 Thread Dieter Menne
Bert Gunter wrote: > > Yes. Don't do this. > > (what you probably really want to do is fit a model with age as a factor, > which can be done statistically e.g. by logistic regression; or > graphically > using conditioning plots, e.g. via trellis graphics (the lattice package). > This avoids the

Re: [R] Data manipulation problem

2010-04-09 Thread moleps
In the end after going at it from scratch...This worked out allright... ##set up data age.cat<-seq(0,100,10) year<-(1953:(1953+55)) dat.vec<-sample(1:10,(length(age.cat)*length(year))) dat.matrix<-matrix(dat.vec,c(length(age.cat),length(year))) rownames(dat.matrix)<-age.cat colnames(

Re: [R] Data manipulation problem

2010-04-07 Thread David Winsemius
That code throws multiple errors. Can you at least test your code before posting? (And, again, please avoid using function names as names for your objects.) -- David. On Apr 7, 2010, at 8:54 AM, moleps islon wrote: So.. here we try again. ##generate dataset age.cat<-seq(0,100,10) year<-

Re: [R] Data manipulation problem

2010-04-07 Thread moleps islon
So.. here we try again. ##generate dataset age.cat<-seq(0,100,10) year<-(1953:(1953+55)) data.vec<-sample(1:1,(age.cat*year)) data.matrix<-matrix(data.vec,c(length(age.cat),length(year)) rownames(data.matrix)<-age.cat colnames(data.matrix)<-year ##divide into 5 year periods age.div<-cut(y

Re: [R] Data manipulation problem

2010-04-06 Thread David Winsemius
On Apr 6, 2010, at 3:30 PM, David Winsemius wrote: On Apr 6, 2010, at 9:56 AM, moleps islon wrote: OK... next question.. Which is still a data manipulation problem so I believe the heading is still OK. ##So now I read my population data from excel. No, you read it from a text file and pro

Re: [R] Data manipulation problem

2010-04-06 Thread David Winsemius
On Apr 6, 2010, at 9:56 AM, moleps islon wrote: OK... next question.. Which is still a data manipulation problem so I believe the heading is still OK. ##So now I read my population data from excel. No, you read it from a text file and providing the first ten lines of that text file should

Re: [R] Data manipulation problem

2010-04-06 Thread moleps islon
OK... next question.. Which is still a data manipulation problem so I believe the heading is still OK. ##So now I read my population data from excel. pop<-read.csv("pop.csv") typeof(pop) ## yields a list where I have age-specific population rows and a yearly column population, where the years are

Re: [R] Data manipulation problem

2010-04-05 Thread moleps
Thx Erik, I have no idea what went wrong with the other code snippet, but this one works.. Appreciate it. qta<- table(cut(age,breaks = seq(0, 100, by = 10),include.lowest = TRUE),cut(year,breaks=seq(1950,2010,by=5),include.lowest=TRUE)) M On 5. apr. 2010, at 21.45, Erik Iverson wrote: > I d

Re: [R] Data manipulation problem

2010-04-05 Thread Erik Iverson
I don't know what your data are like, since you haven't given a reproducible example. I was imagining something like: ## generate fake data age <- sample(20:90, 100, replace = TRUE) year <- sample(1950:2000, 100, replace = TRUE) ##look at big table table(age, year) ## categorize data ## see in

Re: [R] Data manipulation problem

2010-04-05 Thread moleps
I already did try the regression modeling approach. However the epidemiologists (referee) turns out to be quite fond of comparing the incidence rates to different standard populations, hence the need for this labourius approach. And trying the "cutting" approach I ended up with : > table (age5)

Re: [R] Data manipulation problem

2010-04-05 Thread Bert Gunter
You have tempted, and being weak, I yield to temptation: "Any good ideas?" Yes. Don't do this. (what you probably really want to do is fit a model with age as a factor, which can be done statistically e.g. by logistic regression; or graphically using conditioning plots, e.g. via trellis graphics

Re: [R] Data manipulation problem

2010-04-05 Thread Erik Iverson
?cut to create categories ?table to make the table moleps wrote: Dear R´ers. I´ve got a dataset with age and year of diagnosis. In order to age-standardize the incidence I need to transform the data into a matrix with age-groups (divided in 5 or 10 years) along one axis and year divided into 5