[R] Working with data frames
jholtman at gmail.com
Thu Dec 11 16:10:47 CET 2014
If you are using 'read.csv' (or 'read.table') to input, then use the 'as.is
= TRUE' parameter to prevent the conversion to factors of the data.
You can also do "as.character(df$col_with_factors)" to get the character
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Thu, Dec 11, 2014 at 8:00 AM, Sun Shine <phaedrusv at gmail.com> wrote:
> I am struggling with data frames and would appreciate some help please.
> I have a data set of 13 observations and 80 variables. The first column is
> the names of different political area boundaries (e.g. MHad, LBNW, etc),
> the first row is a vector of variable names concerning various census data
> (e.g. age.T, hse.Unk, etc.). The first cell [1,1] is blank.
> I have loaded this via read.csv('path.to/data.set.csv'), and now want to
> run some analyses on this data frame. If I want to get a list of the names
> of the political areas (i.e. the first column), the result is a vector of
> numbers which appear to correlate with the factors, but I don't get the
> text names, just the corresponding number. So, if I want to plot something
> basic, like the area that uses the most gas for central heating, for
> > plot(data.set$ch.Gas)
> The result is the y-axis gives the gas usage for the areas, but the x-axis
> gives only the numbers of the areas, not the names of the areas (which is
> So, two questions:
> (1) have I set up my csv file correctly to be read as a data frame as the
> first row of all of the remaining columns with the values for that
> political area in the corresponding row in the column with the specific
> variable name? So far, looking through tutorials and books seems to suggest
> yes, but at this point I'm no longer sure.
> (2) How can I access the names of the political areas when plotting so
> that these are given on the x-axis instead of the numbers?
> Thanks for any help.
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help