Displaying 2 results from an estimated 2 matches for "ages112".
Did you mean:
aes192
2006 Feb 08
1
adding variable into dataframe by indice
...#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)
asubs112[indce,4] <- prop
asubs112[indce,]
}
Below is the output that I get from the script above. N...
2006 Feb 08
0
insert value according to indice
...Below is an example of the code that 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. N...