search for: yr3

Displaying 12 results from an estimated 12 matches for "yr3".

Did you mean: cr3
2023 Jan 14
2
Removing variables from data frame with a wile card
I have a data frame containing variables "yr3",...,"yr28". How do I remove them with a wild card----something similar to "del yr*" in Windows/doc? Thank you. > colnames(mydata) ? [1] "year"?????? "weight"???? "confeduc"?? "confothr" "college" ? [6] ... ?[41] &...
2023 Jan 14
1
Removing variables from data frame with a wile card
You rang sir? library(tidyverse) xx = 1:10 yr1 = yr2 = yr3 = rnorm(10) dat1 <- data.frame(xx , yr1, yr2, y3) dat1 %>% select(!starts_with("yr")) or for something a bit more exotic as I have been trying to learn a bit about the "data.table package library(data.table) xx = 1:10 yr1 = yr2 = yr3 = rnorm(10) dat2 <- data.table(xx...
2007 Mar 05
1
Matrix/dataframe indexing
Hi all, I am hoping someone can help me out with this: If I have dataframe of years and ages and the first column and first row are filled with leading values: Df<- age1 age2 age3 Yr1 1 0.4 0.16 Yr2 1.5 0 0 Yr3 0.9 0 0 Yr4 1 0 0 Yr5 1.2 0 0 Yr6 1.4 0 0 Yr7 0.8 0 0 Yr8 0.6 0 0 Yr9 1.1 0 0 Now the rest of the cells need to be filled according to the previous year and age cell so arbitrarily, cell [2,2] should be value in cell [1,1] * exp(0.3), and cell [2,3] should be the value in cell [1,2]* exp(0....
2023 Jan 14
2
Removing variables from data frame with a wile card
...ke this to remove the columns starting with yr: > > mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] > >> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> wrote: >> >> I have a data frame containing variables "yr3",...,"yr28". >> >> How do I remove them with a wild card----something similar to "del yr*" >> in Windows/doc? Thank you. >> >>> colnames(mydata) >> [1] "year" "weight" "confeduc" "conf...
2023 Jan 14
1
Removing variables from data frame with a wile card
mydata[, -grep("^yr",colnames(mydata))] On Sat, Jan 14, 2023 at 8:57 AM Steven T. Yen <styen at ntu.edu.tw> wrote: > I have a data frame containing variables "yr3",...,"yr28". > > How do I remove them with a wild card----something similar to "del yr*" > in Windows/doc? Thank you. > > > colnames(mydata) > [1] "year" "weight" "confeduc" "confothr" "colleg...
2023 Jan 14
1
Removing variables from data frame with a wile card
...Then you might write something like this to remove the columns starting with yr: mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> wrote: > > I have a data frame containing variables "yr3",...,"yr28". > > How do I remove them with a wild card----something similar to "del yr*" > in Windows/doc? Thank you. > > > colnames(mydata) > [1] "year" "weight" "confeduc" "confothr" "colleg...
2023 Jan 14
3
Removing variables from data frame with a wile card
...ke this to remove the columns starting with yr: > > mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] > >> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> wrote: >> >> I have a data frame containing variables "yr3",...,"yr28". >> >> How do I remove them with a wild card----something similar to "del yr*" >> in Windows/doc? Thank you. >> >>> colnames(mydata) >> [1] "year" "weight" "confeduc" "conf...
2006 Sep 20
1
Simulation help
...want different trend profiles...the simplest being a linear trend. I've been using the following code: patBdta1 <- NULL for(i in 1:100) patBdta1 <- rbind(patBdta1,c(yr1= mean(rbinom(50,1,.50)), yr2 =mean(rbinom(50,1,.51)), yr3 =mean(rbinom(50,1,.52)), yr4 =mean(rbinom(50,1,.53)), yr5 =mean(rbinom(50,1,.54)))) This code creates 100 data sets each with a 5 yr binomial trend profile with a slope of approximately .01. Now, what I want to do is pass this code...
2023 Feb 12
2
Removing variables from data frame with a wile card
...; >> mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] >> >> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> >> <styen at ntu.edu.tw> wrote: >> >> >> I have a data frame containing variables "yr3",...,"yr28". >> >> >> How do I remove them with a wild card----something similar to "del yr*" >> >> in Windows/doc? Thank you. >> >> >> colnames(mydata) >> >> [1] "year" "weight" &qu...
2023 Jan 14
1
Removing variables from data frame with a wile card
...lumns starting with yr: >> >> mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] >> >>> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> wrote: >>> >>> I have a data frame containing variables "yr3",...,"yr28". >>> >>> How do I remove them with a wild card----something similar to "del yr*" >>> in Windows/doc? Thank you. >>> >>>> colnames(mydata) >>> ? [1] "year"?????? "weight"???? "con...
2023 Jan 15
2
Removing variables from data frame with a wile card
...columns starting with yr: >> >> mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] >> >>> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> wrote: >>> >>> I have a data frame containing variables "yr3",...,"yr28". >>> >>> How do I remove them with a wild card----something similar to "del yr*" >>> in Windows/doc? Thank you. >>> >>>> colnames(mydata) >>> [1] "year"?????? "weight"???? "confe...
2023 Jan 15
0
Removing variables from data frame with a wile card
...lumns starting with yr: >> >> mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] >> >>> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen <styen at ntu.edu.tw> wrote: >>> >>> I have a data frame containing variables "yr3",...,"yr28". >>> >>> How do I remove them with a wild card----something similar to "del yr*" >>> in Windows/doc? Thank you. >>> >>>> colnames(mydata) >>> [1] "year" "weight" "con...