Error In Data Rowvar
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 company Business Learn more r view data about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges r regression Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each
Import Csv Into R
other. Join them; it only takes a minute: Sign up How to solve it. error:Error in data[[rowvar]] : attempt to select less than one element up vote 0 down vote favorite In order to simplify my question, I will
Read.csv R
first show an example of a data file. Data file: clo1 clo2 clo3 1 2 3 1 2 3 5 6 7 R code: read.table("demo.txt", header = TRUE, sep = "\t", row.names = "a") Output: > Error in data[[rowvar]] : attempt to select less than one element In addition: Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on '../demo.txt' r share|improve this question edited Nov 15 '15 at 13:37 Baruchel 2,4711927 asked Nov 15 '15 at 12:50 Justin 11 What is row.names = "a" supposed to achieve? Have you studied the documentation? –Roland Nov 15 '15 at 13:24 yes. I just follow the book's demo. I don't understand what its destination. –Justin Nov 17 '15 at 16:07 I don't know which book your are reading. I was referring to the documentation of the read.table function in help("read.table"). –Roland Nov 17 '15 at 16:10 Doing Data Sciences. I know what you infer. Thanks a lot. –Justin Nov 17 '15 at 17:45 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote The problem is caused by row.names = "a". Data set must have different row names. If you try to name all rows "a", you get the error. If you have a vector which contains the row names you want to use, you can do this. > a <- c("A", "B", "C") > read.table("demo.txt", header = TRUE, row.names = a) clo1 clo2 clo3 A 1 2 3 B 1 2 3 C 5 6 7 share|improve this answer answered Nov 15 '15 at 14:07 Patrick Li 1,38521226 1 Thank you. But I've tried this method. Because it's the demo of my book, i just wanna make sure what led this error. No
Sign in Pricing Blog Support Search GitHub This repository Watch 100 Star 201 Fork 54 Microsoft/RTVS Code Issues 331 Pull requests 3 Projects 0 Pulse Graphs New issue Import from csv: Row names "use number" error #1505 Closed huguesv opened this Issue Apr 8, 2016 · 2 comments Projects None yet Labels area:Variable Explorer priority:P1 status:verified type:bug Milestone Preview 0.3 Assignees JeongPyoHam 3 participants huguesv commented Apr 8, 2016 I'm http://stackoverflow.com/questions/33719867/how-to-solve-it-errorerror-in-datarowvar-attempt-to-select-less-than-one importing that bikes.csv file, and when I select Row Names=Use number, I get an error: Error in data[[rowvar]] : attempt to select less than one element huguesv added type:bug area:Variable Explorer labels Apr 8, 2016 Microsoft member JeongPyoHam commented Apr 8, 2016 Import CSV calls read.csv function, and it could fail with some combinations of input https://github.com/Microsoft/RTVS/issues/1505 parameter depending on the input file. So, error could be by design and the error should show up in UI. The error shows up in REPL as well, however. That part might be annoying. To determine if it is legitimate error, could you share the path to bikes.csv? huguesv commented Apr 8, 2016 \pytools\r\TestData\bikes.csv JeongPyoHam was assigned by MikhailArkhipov Apr 11, 2016 MikhailArkhipov added this to the Preview 0.3 milestone Apr 11, 2016 MikhailArkhipov added the priority:P1 label Apr 11, 2016 JeongPyoHam closed this Apr 11, 2016 huguesv added the status:verified label Apr 11, 2016 Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Reading in tab (and space) delimited data within a scriptXXXX Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Your first email has data3<- "OBSNO AGE SEX ALKPHOS LAB CAMMOL PHOSMMOL AGEGROUP 21 76 M 84 5 https://stat.ethz.ch/pipermail/r-help/2012-January/301069.html 3.2 0.9 3 22 76 M 5 2.18 0.84 3 23 68 M 82 5 2.15 0.52 1 24 69 M 84 5 2.3 1.36 1 25 76 F 100 3 25.3 1.07 3 26 70 F 90 3 20 0.97 2 27 71 F 109 3 22.3 0.94 2 28 70 -99 65 3 24.3 1.42 2 29 74 F 61 3 25 0.87 2 30 74 F 62 3 23.3 0.94 2" Which produces > data3 > data3 [1] "OBSNO AGE error in SEX ALKPHOS LAB CAMMOL PHOSMMOL AGEGROUP\n21 76 M 84 5 3.2 0.9 3\n22 76 M 5 2.18 0.84 3\n23 68 M 82 5 2.15 0.52 1\n24 69 M 84 5 2.3 1.36 1\n25 76 F 100 3 25.3 1.07 3\n26 70 F 90 3 20 0.97 2\n27 71 F 109 3 22.3 0.94 2\n28 70 -99 65 3 24.3 1.42 2\n29 74 F 61 3 25 0.87 2\n30 74 F 62 3 23.3 0.94 2" With the spaces intact (unlike the example you error in data posted in your second email). Running read.table gives an error because the second line is short one variable (no sex apparently): > read.table(textConnection(data3), header=TRUE, row.names="OBSNO") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 2 did not have 8 elements There might be other errors, read.table stops at the first one. Also don't use the same variable for the text data and the Rdata (data3). It will just get confusing. ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Jeff Newmiller Sent: Thursday, January 19, 2012 11:24 AM To: Dan Abner; R. Michael Weylandt Cc: r-help at r-project.org Subject: Re: [R] Reading in tab (and space) delimited data within a script XXXX Cannot see what you are "doing" wrong, since you don't show that. It looks like you have eliminated all delimiters from your input data. Perhaps your editor settings are doing something to your data (though usually tabs if altered become spaces). --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN: