Error In .data.frame X I 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 more about Stack Overflow the
Undefined Columns Selected Subset
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions error in `[.data.frame`(frame, predictors) : undefined columns selected Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
Undefined Columns Selected R Predict
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Undefined columns selected when subsetting data frame up vote 30 down vote favorite 10 I have a data frame, str(data) error in `[.data.frame`(y.data, , mediator) : undefined columns selected to show more about my data frame the result is the following: > str(data) 'data.frame': 153 obs. of 6 variables: $ Ozone : int 41 36 12 18 NA 28 23 19 8 NA ... $ Solar.R: int 190 118 149 313 NA NA 299 99 19 194 ... $ Wind : num 7.4 8 12.6 11.5 14.3 14.9 8.6 13.8 20.1 8.6 ... $ Temp : int 67 72 74 62 56 66 error in data frame object not found 65 59 61 69 ... $ Month : int 5 5 5 5 5 5 5 5 5 5 ... $ Day : int 1 2 3 4 5 6 7 8 9 10 ... However, for example, when I want to subset the amounts of Ozone above 14 I use the following code which gives me an error: > data[data$Ozone > 14 ] Error in [.data.frame(data, data$Ozone > 14) : undefined columns selected database r statistics analytics share|improve this question edited Jun 3 at 5:48 zx8754 16.1k63061 asked Oct 6 '13 at 5:40 CreamStat 5784824 7 you're missing a comma. The error is telling you that you did not indicate which columns to include in your subset. –Ricardo Saporta Oct 6 '13 at 5:52 1 In other words, remember data frame references need row and column identifiers. You can select only one column or all columns, but you need to indicate what you want. –Scott Wilson Feb 14 '15 at 16:14 3 I'm working on the same assignment, so I know this is homework. Weak sauce. –Brian MacKay Jul 11 '15 at 19:48 add a comment| 1 Answer 1 active oldest votes up vote 64 down vote accepted You want rows where that condition is true so you need a comma: data[data$Ozone > 14
multcomp gives unexpected p=1 for all comparisons Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] On Nov 18, 2012, at 6:34
Error In View Undefined Columns Selected
PM, Eiko Fried wrote: > When I run this script on 9 error in $ -.data.frame replacement has rows data has variables, it works without problems. > > Z <- > data > [,c > ("s1_1234_m > ","s2_1234_m >
Error In Data.frame Arguments Imply Differing Number Of Rows
","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 > http://stackoverflow.com/questions/19205806/undefined-columns-selected-when-subsetting-data-frame [,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 https://stat.ethz.ch/pipermail/r-help//2012-November/341172.html 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
- merge.data.frame fails when suffix addition creates duplicate column name Summary: merge.data.frame fails when suffix addition creates duplicate column name Status: CLOSED FIXED https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14786 Alias: None Product: R Classification: Unclassified Component: Language (show other bugs) Version: R 2.14.1 patched Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit Importance: P5 normal Assignee: R-core URL: Depends on: Blocks: Reported: 2012-01-17 21:01 UTC by Aman Verma Modified: 2014-02-16 11:42 UTC (History) CC List: 2 users (show) aman.verma jackie.rosen See Also: Attachments Add an attachment (proposed patch, testcase, etc.) Note You need error in to log in before you can comment on or make changes to this bug. Description Aman Verma 2012-01-17 21:01:19 UTC A bug occurs in merge.data.frame under a situation where a suffix addition for columns with common names creates a situation where one of the two data.frames now has two columns with the same name. This was initially reported at: http://stackoverflow.com/questions/8898905/merge-data-frames-cause-match-names-error/8900743#8900743 Reproducible example: undefined columns selected # Create data. df1=data.frame(rbind(c(1,10,12,NA))) df2=data.frame(rbind(c(11,11))) # Works fine. merge(df1,df2,by=1,all=T) # X1 X2.x X3 X4 X2.y # 1 1 10 12 NA NA # 2 11 NA NA NA 11 # Change the names of the columns. names(df1)= c('v','v2.x','v2.y','v2') names(df2)= c('x','v2') # Same data fails! merge(df1,df2,by=1,all=T) # Error in match.names(clabs, names(xi)) : # names do not match previous names My own short analysis: The error occurs in the "merge.data.frame" method, on this line: x <- rbind(x, ya) The problem is that "x" and "ya" don't share the same column names. That problem occurs on this line, just two lines before the previous one: ya <- cbind(ya, x[rep.int(NA_integer_, nyy), nm.x, drop = FALSE]) nm.x" is a set of names c("v2.x","v2.y","v2.x"). and x is a data.frame with two columns with the name 'v2.x'. Interestingly, when you select the columns from this data.frame, it appears to rename one of the columns! names(x) [1] "v" "v2.x" "v2.y" "v2.x" nm.x [1] "v2.x" "v2.y" "v2.x" x[,nm.x] v2.x v2.y v2.x.1 1 10 12 10 I tried to solve this by using the position of the column, instead of the name, but t