Removing the levels attribute in the output - R

Minions picture Minions · Jun 25, 2015 · Viewed 8.5k times · Source

I am new to R Programming. I wrote a sample program and that returns a value of a particular column in a matrix. When I print the value i get something like this

[1] APPLE
2 Levels : 1 2 

How do I get only the value without the levels in the output.

Thanks in advance.

Answer

Parag picture Parag · Feb 25, 2017

Just to expand on A5C1D2H2I1M1N2O1R2T1's comment, the following command is what prints the variable APPLE without all that levels stuff:

 as.character(APPLE)

To get help on the command within R type:

?as.character

Here is an online R help entry for the command:

https://stat.ethz.ch/R-manual/R-devel/library/base/html/character.html