{"id":207,"date":"2013-05-14T12:58:12","date_gmt":"2013-05-14T17:58:12","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=207"},"modified":"2013-05-14T12:58:12","modified_gmt":"2013-05-14T17:58:12","slug":"open-access-mdb-files-with-rodbc","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2013\/05\/14\/open-access-mdb-files-with-rodbc\/","title":{"rendered":"Open Access .mdb Files with RODBC"},"content":{"rendered":"<p>Getting data into R can be done by reading colon separated files (.csv) via the read.table() function. It is also possible to access databases directly and send SQL queries directly from R to the database. This has some advantages: Using Sweave the queries get documented in the analysis report, variable formats are retained.<\/p>\n<p>To install the RODBC package:<br \/>\n<code>install.packages(\"RODBC\")<\/code><\/p>\n<p>Open a database connection to an Microsoft Access database file, e.g. \u201cMyDataBase.mdb\u201d sitting in the Folder \u201cC:\\ MyPath\\MyDataBase.mdb\u201d:<br \/>\n<code>channel &lt;- odbcConnectAccess(\"C:\/MyPath\/MyDataBase\")<\/code><br \/>\nnote that the Windows backslashes \u201c\\\u201d become slashes \u201c\/\u201d in R and the extension \u201c.mdb\u201d is omitted.<\/p>\n<p>Getting the database table \u201cMyTable\u201d into the R dataframe \u201cR.Table\u201d<br \/>\n<code>R.Table &lt;- sqlQuery( channel , paste (\"select * from MyTable\"))<\/code><br \/>\nMyTable can also be a sql query in the Access database.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting data into R can be done by reading colon separated files (.csv) via the read.table() function. It is also possible to access databases directly&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":0,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}