I need to import many datasets automatically when the first column is a name, so the character vector, and the second column is a number vector, so I used these specifications with read.table: colClasses = c ("character", "numeric").
This works fine if I have a dataframe stored in df_file, like this:
df<- data.frame(V1=c("s1","s2","s3","s4"), V2=c("1e-04","1e-04","1e-04","1e-04") read.table(df_file, header = FALSE, comment.char="", colClasses = c("character", "numeric"), stringsAsFactors=FALSE)
The problem in some cases I have dataframes with numeric values ββin the form of an exponent in the second column, and in these cases the import does not work, because it does not recognize the column as numeric (or imports as a character) "unless I specify colClasses), so my question : how can I specify the column to import as numeric, even if the values ββare exponential?
For instance:
df<- data.frame(V1=c("s1","s2","s3","s4"), V2=c("10^(-4)","10^(-4)","10^(-4)","10^(-4)"))
I want all exponential values ββto be imported as numeric, but even when I try to switch from character to numeric after import, I get all "NA" (as.numeric (as.character (df $ V2)) "Warning message: NAs introduced by duress ")
I tried using "real" or "complex" with colClasses, but it still imports exponents as a symbol.
Please help, thanks!