You can use sapply for this:
dat <- sapply( dat, as.numeric )
If not every column needs converting:
library( taRifx ) dat <- japply( dat, which(sapply(dat, class)=="character"), as.numeric )
Related Posts:
- R Hex to RGB converter
- Counting the number of elements with the values of x in a vector
- Non-numeric Argument to Binary Operator Error in R
- Error in ggplot.data.frame : Mapping should be created with aes or aes_string
- Error in file(file, “rt”) : invalid ‘description’ argument in complete.cases program
- SummarySE (Rmisc package) to produce a barplot with error bars (ggplot2)
- Editing legend (text) labels in ggplot
- Logistic Regression on factor: Error in eval(family$initialize) : y values must be 0 <= y <= 1
- R – longer object length is not a multiple of shorter object length
- Error: attempt to use zero-length variable name
- “non-numeric argument to binary operator” error in R
- Replace all particular values in a data frame
- How can I convert Json to data frame in R
- Error in xj[i] : invalid subscript type ‘list’
- How do you specifically order ggplot2 x axis instead of alphabetical order?
- Error: Invalid number of ‘breaks’ in R
- Sample random rows in dataframe
- Deleting rows that are duplicated in one column based on the conditions of another column
- Replace all 0 values to NA
- What is the meaning of the dollar sign “$” in R function()?
- How can I change the name of a data frame
- In R, dealing with Error: ggplot2 doesn’t know how to deal with data of class numeric
- How do I select the first row in an R data frame that meets certain criteria?
- Poker hand range chart visualization in R
- What does %>% function mean in R?
- How to join (merge) data frames (inner, outer, left, right)
- rbind error: “names do not match previous names”
- rbind error: “names do not match previous names”
- Plotting with ggplot2: “Error: Discrete value supplied to continuous scale” on categorical y-axis
- ggplot2 error : Discrete value supplied to continuous scale
- Error in if/while (condition) {: missing Value where TRUE/FALSE needed
- How do I replace NA values with zeros in an R dataframe?
- How to change legend title in ggplot
- R on MacOS Error: vector memory exhausted (limit reached?)
- Why use as.factor() instead of just factor()
- mean() warning: argument is not numeric or logical: returning NA
- Error in colMeans(x, na.rm = TRUE) : ‘x’ must be numeric in KNN classification
- rmarkdown error “attempt to use zero-length variable name”
- Extract year from date
- incorrect number of dimensions and incorrect number of subscripts in array
- Why am I getting “algorithm did not converge” and “fitted prob numerically 0 or 1” warnings with glm?
- Rotating and spacing axis labels in ggplot2
- How does one reorder columns in a data frame?
- Arcsine transformation of percentage data
- R loop that adds following numbers to each element in list
- R: Using equation with natural logarithm in nls
- Can I calculate z-score with R?
- What does c do in R?
- Using Caret Package but Getting Error in library(e1071)
- Reading PSV (pipe-separated) file or string
- Function to clear the console in R and RStudio
- Manually colouring plots with `scale_fill_manual` in ggplot2 not working
- Calculate correlation for more than two variables?
- Function to clear the console in R and RStudio
- Invalid factor level, NA generated warning
- Error : length of ‘dimnames’ [2] not equal to array extent
- Can’t draw Histogram, ‘x’ must be numeric
- What is the difference between rm() and rm(list=ls())?
- Understanding `scale` in R
- Add empty columns to a dataframe with specified names from a vector
- Convert date-time string to class Date
- Generate a set of random unique integers from an interval
- How do I get RSS from a linear model output
- Warning message: In `…` : invalid factor level, NA generated
- Is there a dictionary functionality in R
- Mean of a column in a data frame, given the column’s name
- Still getting error in dev.off() : cannot shut down device 1 (the null device)
- How to get summary statistics by group
- Run R script from command line
- ‘height’ must be a vector or a matrix. barplot error
- dplyr: “Error in n(): function should not be called directly”
- How do I install an R package from source?
- Error: ggplot2 doesn’t know how to deal with data of class matrix?
- Plotting data in R; error: default method not implemented for type ‘list’
- Changing fonts in ggplot2
- Error in eval(predvars, data, env) : invalid ‘envir’ argument of type ‘character’
- Conditional mean statement
- run a for loop in parallel in R
- Warning in GLM analysis
- Error in na.fail.default: missing values in object – but no missing values
- What does ‘length of ‘dimnames’ [1] not equal to array extent’ mean?
- How to solve it. error:Error in data[[rowvar]] : attempt to select less than one element
- How to prevent scientific notation in R?
- How to declare a vector of zeros in R
- How can I make a list of lists in R?
- Merge data frames based on rownames in R
- The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframe
- Error: isTRUE(gpclibPermitStatus()) is not TRUE
- How to counter the ‘non-numeric matrix extent’ error in R?
- Merge two rows in data.frame
- Get the list of installed packages by user in R
- How to access the last value in a vector?
- Mask output of `The following objects are masked from….:` after calling attach() function
- Construct a manual legend for a complicated plot
- Code to clear all plots in RStudio
- Installing R on Android
- How do I print a hexadecimal number with leading 0 to have width 2 using sprintf?
- How to create lag variables
- When trying to replace values, “missing values are not allowed in subscripted assignments of data frames”
- How to deal with “data of class uneval” error from ggplot2?