-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Vinny Moriarty
Sent: Friday, October 28, 2011 6:05 PM
To: r-help at r-project.org
Subject: [R] Extracting data by row
Thanks everyone for you help with my last question, and now I have one last
one...
Here is a sample of my data in .csv format
site,time_local,time_utc,reef_type_code,sensor_type,sensor_depth_m,temperature_c
06,2006-04-09 10:20:00,2006-04-09 20:20:00,BAK,sb39, 2, 29.63
06,2006-04-09 10:40:00,2006-04-09 20:40:00,BAK,sb39, 2, 29.56
06,2006-04-09 11:00:00,2006-04-09 21:00:00,BAK,sb39, 2, 29.51
06,2006-04-09 11:20:00,2006-04-09 21:20:00,BAK,sb39, 2, 29.53
06,2006-04-09 11:40:00,2006-04-09 21:40:00,BAK,sb39, 10, 29.57
06,2006-04-09 12:00:00,2006-04-09 22:00:00,BAK,sb39, 2, 29.60
06,2006-04-09 12:20:00,2006-04-09 22:20:00,BAK,sb39, 2, 29.66
06,2006-04-09 12:40:00,2006-04-09 22:40:00,BAK,sb39, 10, 29.68
06,2006-04-09 13:00:00,2006-04-09 23:00:00,BAK,sb39, 2, 29.68
My goal was to extract all of the rows from a certain depth. Using the
column "sensor_depth_m" to order my data by, I wanted all of the data from
10m. So this is what I wanted when I finished
site,time_local,time_utc,reef_type_code,sensor_type,sensor_depth_m,temperature_c
06,2006-04-09 11:40:00,2006-04-09 21:40:00,BAK,sb39, 10, 29.57
06,2006-04-09 12:40:00,2006-04-09 22:40:00,BAK,sb39, 10, 29.68
06,2006-04-09 13:00:00,2006-04-09 23:00:00,BAK,sb39, 10, 29.68
To pull out all of the data from a 10m sensor depth I came up with the code:
Ten<-dataTable1[(dataTable1$sensor_depth_m=="10"),]
But when I run it I just get an extra column tacked onto the end like this
site,time_local,time_utc,reef_type_code,sensor_type,sensor_depth_m,temperature_c,
sensor_depth_m
06,2006-04-09 10:20:00,2006-04-09 20:20:00,BAK,sb39, 2, 29.63,10
06,2006-04-09 10:40:00,2006-04-09 20:40:00,BAK,sb39, 2, 29.56,10
06,2006-04-09 11:00:00,2006-04-09 21:00:00,BAK,sb39, 2, 29.51,10
06,2006-04-09 11:20:00,2006-04-09 21:20:00,BAK,sb39, 2, 29.53,10
06,2006-04-09 11:40:00,2006-04-09 21:40:00,BAK,sb39, 10, 29.57,10
06,2006-04-09 12:00:00,2006-04-09 22:00:00,BAK,sb39, 2, 29.60,10
06,2006-04-09 12:20:00,2006-04-09 22:20:00,BAK,sb39, 2, 29.66,10
06,2006-04-09 12:40:00,2006-04-09 22:40:00,BAK,sb39, 10, 29.68,10
06,2006-04-09 13:00:00,2006-04-09 23:00:00,BAK,sb39, 10, 29.68,10
It seems pretty straight forward, I'm not sure what I am missing.
Thanks
V
[[alternative HTML version deleted]]