Displaying 5 results from an estimated 5 matches for "yr2".
Did you mean:
cr2
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...
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.tab...
2006 Sep 20
1
Simulation help
...trying to simulate trend data over a five year period. I 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 appr...
2006 Jun 18
1
Post Stratification
Dear WizaRds,
having met some of you in person in Vienna, I think even more fondly
of this community and hope to continue on this route. It was great
talking with you and learning from you. Thank you. I am trying to work
through an artificial example in post stratification. This is my dataset:
library(survey)
age <- data.frame(id=1:8, stratum=rep(
2023 Jan 14
3
Removing variables from data frame with a wile card
...e 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" "col...