I am a beginner at R and I'm just trying to read a text file that contains values and create a stem display, but I keep getting an error. Here is my code:
setwd("C:/Users/Michael/Desktop/ch1-ch9 data/CH01")
gravity=read.table("C:ex01-11.txt", header=T)
stem(gravity)
**Error in stem(gravity) : 'x' must be numeric**
The File contains this:
'spec_gravity' 0.31 0.35 0.36 0.36 0.37 0.38 0.4 0.4 0.4 0.41 0.41 0.42 0.42 0.42 0.42 0.42 0.43 0.44 0.45 0.46 0.46 0.47 0.48 0.48 0.48 0.51 0.54 0.54 0.55 0.58 0.62 0.66 0.66 0.67 0.68 0.75
If you can help, I would appreciate it! Thanks!
gravity
. Dataframes are not of mode numeric. They are lists. You need to access a dataframe column ... which should be described in any introductory text. – IRTFMread.table("C:/path/to/your/file/ex01-11.txt", header=T)
instead of a filename with a ":" in it. It's possible thatgravity
is empty. – David