Displaying 2 results from an estimated 2 matches for "kunde_real_".
2016 Apr 22
4
Creating variables on the fly
Hi all,
I would like to use a loop for tasks that occurs repeatedly:
# Groups
# Umsatz <= 0: 1 (NICHT kaufend)
# Umsatz > 0: 2 (kaufend)
for (year in c("2011", "2012", "2013", "2014", "2015")) {
paste0("Kunden$Kunde_real_", year) <- (paste0("Kunden$Umsatz_", year) <= 0) * 1 +
(paste0("Kunden$Umsatz_", year) > 0) * 2
paste0("Kunden$Kunde_real_", year) <- factor(paste0("Kunden$Umsatz_", year),...
2016 Apr 26
0
Antwort: Fw: Re: Creating variables on the fly (SOLVED)
...t.org"
<r-help at r-project.org>
> Betreff: Re: [R] Creating variables on the fly
>
> I'm going to assume that Kunden is a data frame, and it has columns
> (variables) with names like
> Umstatz_2011
> and that you want to create new columns with names like
> Kunde_real_2011
>
> If that is so, then try this (not tested):
>
> for (year in 2011:2015) {
> nmK <- paste0("Kunde_real_", year)
> nmU <- paste0("Umsatz_", year)
> cat('Creating',nmK,'from',nmU,'\n')
> Kunden[[ nmK ]] <- if...