CSV file looks like this (modified for brevity). Several columns have spaces in their title and R can't seem to distinguish them.
Alias;Type;SerialNo;DateTime;Main status; [...] E1;E-70;781733;01/04/2010 11:28;8; [...]
Here is the code I am trying to execute:
s_data <- read.csv2( file=f_name )
attach(s_data)
s_df = data.frame(
scada_id=ID,
plant=PlantNo,
date=DateTime,
main_code=Main status,
seco_code=Additional Status,
main_text=MainStatustext,
seco_test=AddStatustext,
duration=Duration)
detach(s_data)
I have also tried substituting
main_code=Main\ status
and
main_code="Main status"
read.csv2
is just a wrapper forread.table
, so it supports the same things. In either case you can usecheck.names=TRUE
to allow spaces in the column names (but it's generally not a good idea) – Ben Bolker May 25 '11 at 12:47str(s_data)
ornames(s_data)
if you're not sure what s_data contains. You would've seen immediately thatMain status
is in factMain.status
. – Joris Meys May 25 '11 at 14:12