Hello, I have this in excel Control 543_BU 123_AT 432_CU I want to be able to import to R so that it will read like this c<-c("543_BU","123_AT","432_CU") output: [1] "543_BU" "123_AT" "432_CU" This is just a short version. I have about 200000 rows and i need a simpler way instead of typing each one. thanks -- View this message in context: http://www.nabble.com/Excel-export-into-R-tp15863252p15863252.html Sent from the R help mailing list archive at Nabble.com.
There are a number of ways for importing from EXCEL. For example if you were to create a CSV file for EXCEL, you can read it like:> x <- read.table('/tempxx.txt.r', header=TRUE, as.is=TRUE) > xControl 1 543_BU 2 123_AT 3 432_CU On Wed, Mar 5, 2008 at 6:42 PM, Keizer_71 <christophe.lo at gmail.com> wrote:> > Hello, > > I have this in excel > > Control > 543_BU > 123_AT > 432_CU > > > I want to be able to import to R so that it will read like this > > c<-c("543_BU","123_AT","432_CU") > > output: > [1] "543_BU" "123_AT" "432_CU" > > This is just a short version. I have about 200000 rows and i need a simpler > way instead of typing each one. > > thanks > -- > View this message in context: http://www.nabble.com/Excel-export-into-R-tp15863252p15863252.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
> I have this in excel > > Control > 543_BU > 123_AT > 432_CU > > > I want to be able to import to R so that it will read like this > > c<-c("543_BU","123_AT","432_CU")See the help page for read.csv ?read.csv ...and the R Data Import/Export manual http://cran.r-project.org/doc/manuals/R-data.html Two things to remember: 1. It will be much more straightforward if you save your excel spreadsheet as a CSV file, rather than the Excel native format. 2. read.csv will import the data as a data frame rather than a vector, and will by default coerce the strings to factors. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
Hi Richie, I apologize. I thought i deleted this thread since it is resolved by using scan() function. thank you again, Kei Richard Cotton wrote:> >> I have this in excel >> >> Control >> 543_BU >> 123_AT >> 432_CU >> >> >> I want to be able to import to R so that it will read like this >> >> c<-c("543_BU","123_AT","432_CU") > > See the help page for read.csv > ?read.csv > > ...and the R Data Import/Export manual > http://cran.r-project.org/doc/manuals/R-data.html > > Two things to remember: > 1. It will be much more straightforward if you save your excel spreadsheet > as a CSV file, rather than the Excel native format. > 2. read.csv will import the data as a data frame rather than a vector, and > will by default coerce the strings to factors. > > Regards, > Richie. > > Mathematical Sciences Unit > HSL > > > ------------------------------------------------------------------------ > ATTENTION: > > This message contains privileged and confidential inform...{{dropped:20}} > > ______________________________________________ > 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. > > > ----- > Regards, > Richie. > > Mathematical Sciences Unit > HSL >-- View this message in context: http://www.nabble.com/Excel-export-into-R-tp15863252p15870982.html Sent from the R help mailing list archive at Nabble.com.
Keizer_71 wrote:> > I have this in excel > > Control > 543_BU > 123_AT > 432_CU > > I want to be able to import to R so that it will read like this > > c<-c("543_BU","123_AT","432_CU") > > output: > [1] "543_BU" "123_AT" "432_CU" > > This is just a short version. I have about 200000 rows and i need a simpler > way instead of typing each one. >It would be nice if you could give a reproducible example, like giving the xls spreadshit as a xml file, so that it makes it easy to reproduce the example. For example, I had some trouble with read.xls, but I could figure out (by rtfming) what the problem was. But if I hadn't solved the problem, I would have asked here, by composing a reproducible example. The unsent message would have been like this: --- begin of fictional message --- Hello, I have a problem with read.xls. Take this xml file, convert to test.xls (using Excel) and read in R using x <- read.xls("test.xls") <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Worksheet ss:Name="Plan1"> <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="3" x:FullColumns="1" x:FullRows="1"> <Row> <Cell><Data ss:Type="String">roman</Data></Cell> <Cell><Data ss:Type="String">greek</Data></Cell> <Cell><Data ss:Type="String">height</Data></Cell> </Row> <Row> <Cell><Data ss:Type="String">Marte</Data></Cell> <Cell><Data ss:Type="String">Ares</Data></Cell> <Cell><Data ss:Type="Number">1.9</Data></Cell> </Row> <Row> <Cell><Data ss:Type="String">Venus</Data></Cell> <Cell><Data ss:Type="String">Aphrodite</Data></Cell> <Cell><Data ss:Type="Number">1.6</Data></Cell> </Row> </Table> </Worksheet> </Workbook> I want to have a list of the planet names in roman, but x[,1] is not an array of strings, and cat(x[,1]) gives an error. --- end of fictional message --- FWIW, the reply to this message is: y <- as.matrix(x) cat(y[,1]) Alberto Monteiro