I'm trying to use R for the first time to make a histogram. I have a file containing one column of 100,000 floating-point numbers ranging in size from 8.85543e-07 to 1.15469e-03. R apparently doesn't recognize them as floating-point numbers because of the 'e' notation. How can I get R to read them. Thanks!
R can read such numbers just fine; there must be another value in there that's causing the problem.
If you read in your data using read.table
/read.csv
/read.delim
, you can always convert your data to numeric if it didn't import correctly.
x <- as.numeric(as.character(df$x))
where df
is the name of your data frame, and x
is the column that you want.
Read the file like this:
file_as_data_frame <- read.table("file.txt", colClasses="numeric")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With