I've tried to follow the reprex guide, although I am a little confused by the dataset bit. So this is an example of my data set with two important variables - lettered classification of the respondents and the organisations they are involved in.
#>
data.frame(stringsAsFactors=FALSE,
org = c(NA, NA, NA, "Organisation A",
"Organisation A",
"Organisation A", "Organisation A",
"Organisation A",
"Organisation A", "Organisation A",
"Organisation A",
"Organisation A", "Organisation A",
"Organisation A", "Organisation A",
"Organisation A",
"Organisation A", "Organisation A", NA,
"Organisation X,Organisation A",
"Organisation X,Organisation A",
"Organisation X,Organisation A",
"Organisation A", "Organisation X,
Organisation A", "Organisation X,
Organisation A", "Organisation X,
Organisation A", NA, "Organisation X", "Organisation X",
"Organisation X"),
Class = c(NA, NA, NA, "A", "A", "N/A", "B", "C1", "B", "D", "B", "B",
"D", "C1", "B", "D", "E", "B", NA, "B", "C1", "C2", "A",
"N/A", "S", "B", NA, "B", "S", "B")
)
Now I want to try and code the organisations each respondent is involved with (A,X, etc), but as some are involved in multiple, I need them to be coded as both A and X. I originally tried code like this:
#>
and it wouldn't work. Following PJ, I have now been trying this:
#>Data=data.frame(person=sample(1:51,43,replace=T)org=sample(LETTERS[1:3],43,replace=T))%>%group_by(person,org)%>%summarise()
But have been receiving this error message:
#>Error: unexpected symbol in "Data=data.frame(person=sample(1:51,43,replace=T)org"
I am wondering if it is easier to just copy the data of the respondents who are part of more than one org and code one as one org and one as the other.