Displaying 2 results from an estimated 2 matches for "first_drink".
2006 Feb 08
1
adding variable into dataframe by indice
...give you an idea, but the original has 'NA' in many rows. The original data is what is reported in the output below.
#Read in Data
age.int <- data.frame(IND_ID = seq(1, 140, 10), rs1042364 = sample( c("(1,1)","(1,2)","(2,2)"),14,replace = T),
first_drink = sample(5:17,14,replace = T))
asubs112 <- subset(age.int, rs1042364 != "(2,2)")
ages112 <- sort(unique(na.omit(asubs112$first_drink)))
for ( i in ages112) {
indce <- which(na.omit(asubs112$first_drink == i))
prop <- length(indce)/nrow(asubs112...
2006 Feb 08
0
insert value according to indice
...I am using. I have also attached the data file that I am using to create this dataframe.
#Read in Data
age.int <- read.csv('C:/intage.csv',header = TRUE)
asubs112 <- subset(age.int, rs1042364 != "(2,2)")
ages112 <- sort(unique(na.omit(asubs112$first_drink)))
for ( i in ages112) {
indce <- which(na.omit(asubs112$first_drink == i))
prop <- length(indce)/nrow(asubs112)
asubs112[indce,5] <- prop
asubs112[indce,]
}
Below is the output that I get from the script above. Notice the proportion for the first NA but not a...