I am trying to simply use rbind
for two columns and I use the following (all variables are city names and r considers them as factor)
firstcitynames <- rcffull$X1CityName
secondcitynames <- rcffull$X2CityName
allcitynames <- rbind(firstcitynames, secondcitynames)
allcitynames
then when get to View(allcitynames)
all I get is a bunch of numbers instead of names:
[,2276] [,2277] [,2278] [,2279] [,2280] [,2281]
[,2282] [,2283] [,2284] [,2285] [,2286] [,2287]
Any suggestions?
You need to convert factors to characters with as.character(df$var)
Here's an illustration
a <- factor(letters[1:10])
b <- factor(LETTERS[1:10])
rbind(a,b)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## a 1 2 3 4 5 6 7 8 9 10
## b 1 2 3 4 5 6 7 8 9 10
rbind(as.character(a), as.character(b))
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
## [2,] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"