I’m learning some of R this days, I have some data on a file:
0.7300719696546073 0.5508739992014652 0.2371535688287479
0.9359803887798046 0.8249035576959065 0.3715476175169042
0.3403916445508408 0.8036890953987708 0.8079012937499597
Just like that… (but way bigger)
data = read.table("data.txt")
In some operations I would like to have all the data on a single vector to use hist(data)
but I get: 'x' must be numeric
I tried different stuff like as.vector(data) or lapply(c(data), as.numeric) but nothing works.
Would you give me a hand?
SOLVED: unlist(data)
PS: Expected to not work since I have a table of 100(cols)*5000(rows)
will do the trick. This is an easy way to transform a data frame to a vector.
With your data:
The result is a vector (with named elements) :
If you don’t want to have the names, use the argument
use.names = FALSEinunlist: