Hi All,
I thought dataset$variable is the same as dataset["variable"]. I tried the
following:
> str(ZWW_Kunden$Branche)
chr [1:49673] "231" "151" "151" "231" "231" "111" "231" "111" "231" "231"
"151" "111" ...
> str(ZWW_Kunden["Branche"])
'data.frame': 49673 obs. of 1 variable:
$ Branche: chr "231" "151" "151" "231" ...
and get different results: "chr {1:49673]" vs. "data.frame". First one is
a simple vector, second one is a data.frame.
This has consequences when subsetting a dataset and filter cases:
> ZWW_Kunden["Branche"] %in% c("315", "316", "317")
[1] FALSE
> head(ZWW_Kunden$Branche %in% c("315", "316", "317")) # head() only to
shorten output
[1] FALSE FALSE FALSE FALSE FALSE FALSE
I have thought dataset$variable is the same as dataset["variable"] but
actually it's not.
Can you explain what the difference is?
Kind regards
Georg
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.