3

Possible Duplicate:
dropping factor levels in a subsetted data frame in R

I would like to get the text from a cell in a data frame (and use that text to create a file). However, whenever I select a specific row and column from the data frame, the result is the contents of the data frame followed by a list of levels from the data frame. For example:

getFileNameTest<-function(
   columnNames=c(cName1,cName2)
)
{
list1<-c("joe", "bob", "sue")
list2<-c("jones","smith","smith")
myDataFrame<-data.frame(list1,list2)

joeFileName<-myDataFrame[1,1]
return(joeFileName)

}

This function returns:

[1] joe
Levels: bob joe sue

But I would like just "joe" so that I can later create a file named "joe." How do I grab the contents of a specific row and column in a data frame without returning the levels?

Community
  • 1
  • 1
Docuemada
  • 1,703
  • 2
  • 25
  • 44

1 Answers1

2

as @joran suggests or:

df <- data.frame(x=sample(LETTERS,10))
df[,1][[1]]

as.character(df[,1][[1]])
user1317221_G
  • 15,087
  • 3
  • 52
  • 78