0

I would like to remove the chief physicians from the characteristic professional position and remove the characteristic employed from the characteristic employment relationship (self-employed or employed). Subsequently, all employed chief physicians are to be compared with all other employed physicians without the professional position of chief physician. I now have the difficulty how to represent this in a contingency table, let alone in a barplot.

First, I thought about creating two dataframes. Is it possible to proceed like this? Subsequently, one could do this in the table function? But it is not working...

Chefarzt<-subset(daten0,Position.EM=="Chefarzt",Arbeitsverhaeltnis.EM=="angestellt")
Aerzte<- subset(daten0, Position.EM!="Chefarzt",Arbeitsverhaeltnis.EM=="angestellt")

Chefarzt <- as.factor(daten0$Chefarzt)
Aerzte<- as.factor(daten0$Aerzte)

tabChefAe<-table(daten0$Chefarzt,daten0$Aerzte)
tabChefAe

result: table of extent 0 x 0 >

user438383
  • 5,716
  • 8
  • 28
  • 43
  • 2
    Welcome. You will have to be a **lot** more clear about your question - we have no idea what 'remove the chief physicians from the characteristic professional position' means, for example. Please share a reproducible example of your data and provide some kind of expected output. Thanks. – user438383 Nov 04 '21 at 17:18
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Nov 04 '21 at 17:59
  • Check your code. `variable <- subset(dataframe, ....)` "filters" rows with the condition from `daten0` and assigns them to the variables `Chefarzt` and `Aerzte`. Then you "overwrite" these variables by assigning a column ($-notation) of `daten0` (and turning this into a factor. With `tabChefAe` you want to create a contingency table of these "columns". I assume you do not want to overwrite the filtered sub-dataframes ... or ... you could have safely let this out here. Your `daten0` dataframe has no `Chefarzt` or `Aerzte` column. Thus, you overwrite empty/NAs and try to table() := extent 0 x 0. – Ray Nov 04 '21 at 18:38

0 Answers0