Just following on Matt and Dirk. If you want to recreate your existing data frame without changing the global option, you can recreate it with an apply statement:
bob <- data.frame(lapply(bob, as.character), stringsAsFactors=FALSE)
This will convert all variables to class “character”, if you want to only convert factors, see Marek’s solution below.
As @hadley points out, the following is more concise.
bob[] <- lapply(bob, as.character)
In both cases, lapply
outputs a list; however, owing to the magical properties of R, the use of []
in the second case keeps the data.frame class of the bob
object, thereby eliminating the need to convert back to a data.frame using as.data.frame
with the argument stringsAsFactors = FALSE
.
Related Posts:
- Create empty data frame with column names by assigning a string vector?
- Insert a blank column in dataframe
- Convert data.frame column to a vector?
- Converting from a character to a numeric data frame
- how to sort pandas dataframe from one column
- How to reset index in a pandas dataframe? [duplicate]
- How to iterate over rows in a DataFrame in Pandas
- Writing a pandas DataFrame to CSV file
- How can I use the apply() function for a single column?
- How to groupby based on two columns in pandas?
- Merging dataframes on index with pandas
- How to replace NaN values by Zeroes in a column of a Pandas Dataframe?
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- Pandas group-by and sum
- How to resolve TypeError: ‘No Numeric Data to Plot’, when numeric data exists in Python
- pandas: filter rows of DataFrame with operator chaining
- ‘DataFrame’ object has no attribute ‘sort’
- How to read a .xlsx file using the pandas Library in iPython?
- Get total of Pandas column
- Change column type in pandas
- Plot multiple lines in one graph
- Changing font size and direction of axes text in ggplot2
- What does axis in pandas mean?
- Warning message: line appears to contain embedded nulls [duplicate]
- How to change line width in ggplot?
- Error in library(ggplot2) : There is no package called ‘ggplot2’
- How to drop columns by name in a data frame
- Combine two columns of text in pandas dataframe
- How to reshape data from long to wide format
- Change size of axes title and labels in ggplot2
- Python: pandas merge multiple dataframes
- Multiple If Statements in R
- How to count the NaN values in a column in pandas DataFrame
- ggplot2, change title size
- Combine two or more columns in a dataframe into a new column with a new name
- Pandas – DataFrame object is not callable
- R “Error: unexpected ‘}’ in “}”
- How to create an empty matrix in R?
- Normalize columns of pandas data frame
- Normalize columns of pandas data frame
- How to filter Pandas dataframe using ‘in’ and ‘not in’ like in SQL
- How to increase font size in a plot in R?
- Position-dodge warning with ggplot boxplot?
- How to apply a function to two columns of Pandas dataframe
- Error in rep(1, n.ahead) : invalid ‘times’ argument in R
- Producing subscripts in R markdown
- ggplot geom_text font size control
- lme4::lmer reports “fixed-effect model matrix is rank deficient”, do I need a fix and how to?
- How do you use “<<-" (scoping assignment) in R?
- OSError: Initializing from file failed on csv in Pandas
- Re-ordering factor levels in data frame
- Understanding the result of modulo operator: %%
- Simple manual RMarkdown tables that look good in HTML, PDF and DOCX
- Select rows from a data frame based on values in a vector
- how to increase the limit for max.print in R
- Insert a row to pandas dataframe
- Subtract two columns in dataframe
- backward elimination in R
- Pandas error “Can only use .str accessor with string values”
- How to compute summation in r
- Plot multiple boxplot in one graph
- R will plot but won’t draw abline
- scale_fill_discrete and scale_fill_manual – legend options confusion
- R – argument is of length zero in if statement
- ‘Incomplete final line’ warning when trying to read a .csv file into R
- Rename specific column(s) in pandas
- Merging data – Error in fix.by(by.x, x)
- R error: “New Column would leave holes after existing columns”
- Error in 2:n : NA/NaN argument
- Error in generating boxplot two variable data frame: adding class “factor” to an invalid object
- Error : Unable to start png() device
- Remove NA values from a vector
- How to catch integer(0)?
- Coalesce values from 2 columns into a single column in a pandas dataframe
- r random forest error – type of predictors in new data do not match
- env=baseenv() in R
- How to set axis range R
- Move column by name to front of table in pandas
- What does the error “object not interpretable as a factor” mean?
- Gradient of n colors ranging from color 1 and color 2
- What is the difference between require() and library()?
- R Sweave: NO TeX installation detected
- Plotting legend outside plot in R
- Boolean operators && and ||
- R avoiding “restarting interrupted promise evaluation” warning
- do-while loop in R
- Pandas dataframe groupby plot
- ERROR: [on_request_read] connection reset by peer in R shiny
- Error in as.vector(x, mode) : cannot coerce type ‘closure’ to vector of type ‘any’
- Suppress output of a function
- Get dplyr count of distinct in a readable way
- r function unzip error 1 in extracting from zip file
- Colour points in a plot differently depending on a vector of values
- increase legend font size ggplot2
- How To Create Vector of Vector In R
- Round down a numeric
- Use of ~ (tilde) in R programming Language
- Does the c command create a row vector or a column vector by default in R
- Can dplyr join on multiple columns or composite key?
- Convert list of dictionaries to a pandas DataFrame