Displaying 2 results from an estimated 2 matches for "asubs112".
2006 Feb 08
1
adding variable into dataframe by indice
...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)
asubs112[indce,4] <- prop
asubs112[in...
2006 Feb 08
0
insert value according to indice
...to only those individuals with the specified value for that proportion.
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[in...