# problem with factors

#### Tart

##### New Member
I'm experiencing some weird problem.

I wrote a function and this its final output
Code:
  return(list(Results=data.frame(Latitude=final.lat, Longitude=final.lgt,
Elevation=final.elv,
Distance=final.distance,
Type=as.character(final.type),
Name=as.character(final.name),
Notes=as.character(final.notes)),
Elevation.Errs = elv.errs,
c.rate=c.rate, Lines=lines)
)
Problems is when I call my function my in output$Results Type, Name, Notes, are all factors now. I specifically put as.character in the code to try and avoid this, but it didn't help. Code: List of 4$ Results       :'data.frame': 1779 obs. of  7 variables:
..$Latitude : num [1:1779] 33.2 33.2 33.2 33.2 33.2 ... ..$ Longitude: num [1:1779] -80.5 -80.5 -80.5 -80.5 -80.5 ...
..$Elevation: num [1:1779] 47.4 47.3 46.7 46.1 45.5 ... ..$ Distance : num [1:1779] 32.7 32.7 32.7 32.8 32.8 ...
..$Type : Factor w/ 4 levels "CROSSING","MILEPOST",..: 4 1 4 4 4 4 4 4 4 4 ... ..$ Name     : Factor w/ 192 levels "40-1439","ANN STREET",..: 174 41 174 174 174 174 174 174 174 174 ...
..$Notes : Factor w/ 79 levels "10497","11540",..: 77 76 77 77 77 77 77 77 77 77 ...$ Elevation.Errs: num [1:126172] -0.000453 -0.003504 -0.004238 -0.007289 -0.01034 ...
$c.rate : num 98.6$ Lines         :'data.frame': 1778 obs. of  6 variables:
..$X1 : num [1:1778] 32.7 32.7 32.7 32.8 32.8 ... ..$ Y1       : num [1:1778] 47.4 47.3 46.7 46.1 45.5 ...
..$X2 : num [1:1778] 32.7 32.7 32.8 32.8 32.9 ... ..$ Y2       : num [1:1778] 47.3 46.7 46.1 45.5 44.7 ...
..$intercept: num [1:1778] 447 500 440 466 553 ... ..$ slope    : num [1:1778] -12.2 -13.8 -12 -12.8 -15.5 ...
How to avoid this? I need those as text, not factors.
I know I can do post processing like
Code:
output$Results$Type <- as.character(output$Results$Type
but I would like to avoid this. Is this problem with the list?
Thanks!