I cannot insert the correct data into a dataframe using rbind. Here is the problem
Results <- dataframe()
The value will store the hospital name that matches the selection criteria, and y [1,2] the state name
This is what I get when I try to do the results as empty data.
class(results)
[1] "data.frame"
value
[1] "JOHN C LINCOLN DEER VALLEY HOSPITAL"
y[1,2]
[1] "AZ"
class(value)
[1] "character"
class(y[1,2])
[1] "character"
results <- rbind(results,as.list(c(value,y[1,2])))
Warning messages:
1: In `[<-.factor`(`*tmp*`, ri, value = "JOHN C LINCOLN DEER VALLEY HOSPITAL") :
invalid factor level, NA generated
2: In `[<-.factor`(`*tmp*`, ri, value = "AZ") :
invalid factor level, NA generated
results
X.ARKANSAS.METHODIST.MEDICAL.CENTER. X.AR.
1 ARKANSAS METHODIST MEDICAL CENTER AR
2 <NA> <NA>
3 <NA> <NA>
How to solve this? Many thanks
source
share