(As a noob to R, this is my first posting - yes yes, groans all around...) I'm trying to extract certain rows from a data frame. I used the following to import data from a CSV txt file.
data <- read.table(file="data.txt", header=TRUE) when I do this, my attempt to extract the data rows only from where the Station value equals 1… data.station1 <- data[data$Station == 1] ...is giving me the following error message: Error in `[.data.frame`(data, data $Station == 1) : undefined columns selected Bah. If I use names(data) I can see "Station" as a column name. And if I use str(data), the variable "Station" is coming up as integers including the value 1. And if I use data$Station, I see all station values, including the 1s. And if I use data[,"Station"] I do see all the Station values And if I instead treat the Station values as characters, by using "1", I still get the "undefined" error. Could someone please correct me on my syntax? Or advise if perhaps I imported the data the wrong way? I'm working out of "A Beginner's Guide to R" and also looked through the R manual, and even tried this from Google search: data.station1 <- data,("Station" == 1) ] But that gave me an unwanted output: data frame with 0 columns and 789 rows Almost, but not quite. Please help? Thank you, - Suzanne .......................................... suzanne.mert...@gmail.com 404-337-1533 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.