R Error In Data Frame Undefined Columns Selected
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn
Undefined Columns Selected R Sort
more about Stack Overflow the company Business Learn more about hiring developers or posting error in `[.data.frame`(frame, predictors) : undefined columns selected ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community
Error In `[.data.frame`(y.data, , Mediator) : Undefined Columns Selected
Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error in data frame undefined columns selected up vote 1 undefined columns selected r predict down vote favorite I've been working on an assignment where I have to read in some csv files from a directory "specdata". The files are very similar in that there are 332 titled 001.csv - 332.csv. They have consistent columns and headers, if that matters. I believe I'm close but am tripping up with the above error message " Error in [.data.frame(data1, good) : undefined columns selected" I undefined columns selected r shiny had expected a data frame to load with all the data specified by the subset of files in id parameter. pollutantmean <- function(directory, pollutant, id = 1:332) { files <- list.files(directory) subsetFiles <- files[id] for (i in subsetFiles) { filepaths <- paste(directory,"/",i, sep='') data1 <- read.csv(filepaths) } data1 good <- complete.cases(data1) data2 <- data1[good] data2 } # test it out and ignore middle parameter for now pollutantmean("specdata", "pass", 1:3) r share|improve this question edited Oct 23 '14 at 13:29 Cerbrus 35.6k66194 asked May 14 '14 at 23:04 Doug Fir 2,805164192 add a comment| 2 Answers 2 active oldest votes up vote 5 down vote accepted Are you meaning? data2 <- data1[good,] With data1[good] you're selecting columns in a wrong way (using a logical vector of complete rows). Consider that parameter pollutant is not used; is it a column name that you want to extract? if so it should be something like data2 <- data1[good, pollutant] Furthermore consider that you have to rbind the data.frames inside the for loop, otherwise you get only the last data.frame (its completed.cases) And last but not least, i'd prefer generating filenames eg with id <- 1:322 paste0( directory, "/", gsub(" ", "0", sprintf("%3d",id)), ".csv") A little modified
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn
Error In `[.data.frame`(data, , All.vars(terms), Drop = False)
more about Stack Overflow the company Business Learn more about hiring developers or posting error in data frame object not found ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community
Error In $ -.data.frame ( *tmp*
Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error in R “undefined columns selected” up vote 4 down http://stackoverflow.com/questions/23666611/error-in-data-frame-undefined-columns-selected vote favorite Hi I am still a newbie to R. Right now I am trying to initiate this code using the zoo command: gld <- zoo(gld[,7], gld_dates) Unfortunately I get an error message telling me this: Error in `[.data.frame`(gld, , 7) : undefined columns selected I want to use the zoo function to create zoo objects from my data. The function should take two arguments: a vector of http://stackoverflow.com/questions/7398126/error-in-r-undefined-columns-selected data and a vector of dates. This is the data I am using: http://ichart.finance.yahoo.com/table.csv?s=GLD&a=08&b=13&c=2007&d=08&e=13&f=2011&g=d&ignore=.csv I believe I have have 7 columns in my data set. Any ideas? Thank you The code I am trying to implement is found here: http://quanttrader.info/public/testForCoint.html Is their anything wrong with this code? Thanks - R r share|improve this question edited Sep 13 '11 at 16:44 asked Sep 13 '11 at 7:14 Rachel 21113 1 It might be worth double checking the number of columns: you can use the ncol function for this. –MatthewS Sep 13 '11 at 17:02 I just ran all the gld parts of the code from your website without errors. Could you reload your data and then run the command str(gld) and post the results so we can be sure you're starting in the right place? –Gregor Sep 13 '11 at 17:29 Well what was the problem? and the solution? –smci May 2 '14 at 23:55 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote You don't say what your gld_dates is exactly, but if gld starts as your original data and you want to make a zoo object of the 7th column ordering b
multcomp gives unexpected p=1 for all comparisons Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] On Nov 18, 2012, at 6:34 https://stat.ethz.ch/pipermail/r-help//2012-November/341172.html PM, Eiko Fried wrote: > When I run this script on 9 variables, it works without problems. > > Z <- > data > [,c > ("s1_1234_m > ","s2_1234_m > ","s3_1234_m > ","s4_1234_m > ","s5_1234_m","s6_1234_m","s7_1234_m","s8_1234_m","s9_1234_m" > )] > > However, when I run the script on 9 different variables, it does not > work: > Z <- > data > error in [,c > ("d_s1_m > ","d_s2_m > ","d_s3_m","d_s4_m","d_s5_m","d_s6_m","d_s7_m","d_s8m","d_s9m" > )] > > Error in `[.data.frame`(data, , c("d_s1_m", "d_s2_m", "d_s3_m", > "d_s4_m", > : > undefined columns selected You have probably misspelled one or more the column names. For instance I suspect that one or both of these might be lacking a second "_" : "d_s8m","d_s9m" If you feel thsi is wrong undefined columns selected then you at the very least need to offer str(data) BTW, data is the name of a perfectly good function, so naming your dataframe "data" is likely to create confusion. -- David. > > The first 9 variables are between 0 and 3, there are no missing > values in > the dataset. > > The second 9 variables are between -3 and 3, there are no missing > values in > the dataset. > > I am pretty new to R and have no idea what could cause this error. > > Thank you > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. David Winsemius, MD Alameda, CA, USA Previous message: [R] Error in `[.data.frame`... undefined columns selected Next message: [R] glht function in multcomp gives unexpected p=1 for all comparisons Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] More information about the R-help mailing list