Message from Winston Cheng of R Studio.
—-
Message from Winston Cheng of R Studio.
—-
Using the dir() and list.files() commands lists all the files in a particular directory. These can be interactively read by R, by referencing to specific parts of the list created by the above two commands. This is useful when you are working with a large number of files, that get generated or re-generated after specific time periods (like web server log files)
> getwd()
[1] “C:/Users/KUs/Documents”
> path=”C:/Users/KUs/Desktop/tester”
> dir(path)
[1] “tester.csv” “tester2.csv” “tester3.csv””tester4.csv”
> setwd(path)
> read.table(file=dir(path)[1],sep=”t”,header=T)
X1 X2 X3 X4
1 to be 2 B
> read.table(file=dir(path)[4],sep=”,”,header=T)
zoo bee doo bee.1 daa
1 12 32 43 34 qwerty
Lets assume that the big bad world of American electoral politics forces some kind of modified SOPA to be passed, and the big American companies have to abide by that law (just as they do share data for National Security under Patriot Act but quitely).
I belive Opera Unite is the way forward to sharing content on the Internet.
From-
http://dev.opera.com/articles/view/opera-unite-developer-primer-revisited/
Opera Unite features a Web server running inside the Opera browser, which allows you to do some amazing things. At the touch of a button, you can share images, documents, video, music, games, collaborative applications and all manner of other things with your friends and colleagues
I can share music, and files , and the web server is actually my own laptop. try beating 2 billion new web servers that sprout!! File system sharing is totally secure- you can create private, public, or password protected files, a messaging system that can be used for drop messages (called fridge), a secure messaging system and your own web server is ready to start at a click. the open web may just use opera instead of chromium, and US regulation would be solely to blame. even URL blocking is of limited appeal thanks to software like MafiaWire Extension
Throw in Ad block, embedded bit torrent sharing and some more Tor level encryption within the browser and sorry Senator, but the internet belongs to the planet not to your lobbyist.
My guest blog at Allanalytics.com is now up
http://www.allanalytics.com/ is the exciting community which looks at the business aspects to the analytics market with a great lineup of pedigree writers.
It is basically a point/counterpoint for and against open source analytics. I feel there is a scope of lot of improvement before open source dominates the world of analytics software like Android, Linux Web Server do in their markets. Part of this reason is – there needs to be more , much more investment in analytics research, development, easier to use interfaces, Big Data integration and rewarding ALL the writers of code regardless of whether the code is proprietary or open source.
A last word- I think open source analytics AND proprietary analytics software will have to learn to live with one another, with game theory dictating their response and counter-response. More competition is good, and open source is an AND option not an OR option to existing status quo.
You can read the full blog discussion at http://www.allanalytics.com/author.asp?section_id=1408&doc_id=233454&piddl_msgorder=thrd#msgs
Hopefully discussion would be more analytical than passionate 🙂 and greater investments in made in analytics by all sides.
But after all that- I was quite happy to see Google Fusion Tables within Google Docs. Databases as a service ? Not quite but still quite good, and lets see how it goes.
https://www.google.com/fusiontables/DataSource?dsrcid=implicit&hl=en_US&pli=1
http://googlesystem.blogspot.com/2011/09/fusion-tables-new-google-docs-app.html
But what interests me more is
http://code.google.com/apis/fusiontables/docs/developers_guide.html
The Google Fusion Tables API is a set of statements that you can use to search for and retrieve Google Fusion Tables data, insert new data, update existing data, and delete data. The API statements are sent to the Google Fusion Tables server using HTTP GET requests (for queries) and POST requests (for inserts, updates, and deletes) from a Web client application. The API is language agnostic: you can write your program in any language you prefer, as long as it provides some way to embed the API calls in HTTP requests.
The Google Fusion Tables API does not provide the mechanism for submitting the GET and POST requests. Typically, you will use an existing code library that provides such functionality; for example, the code libraries that have been developed for the Google GData API. You can also write your own code to implement GET and POST requests.
Also see http://code.google.com/apis/fusiontables/docs/sample_code.html
Language | Library | Public repository | Samples |
---|---|---|---|
Python | Fusion Tables Python Client Library | fusion-tables-client-python/ | Samples |
PHP | Fusion Tables PHP Client Library | fusion-tables-client-php/ | Samples |
An easy way to learn how to use an API can be to look at sample code. The table above provides links to some basic samples for each of the languages shown. This section highlights particularly interesting samples for the Fusion Tables API.
Language | Featured samples | API version |
---|---|---|
cURL |
|
SQL API |
Google Apps Script |
|
SQL API |
Java |
|
SQL API |
Python |
|
Docs List API |
Android (Java) |
|
SQL API |
JavaScript – FusionTablesLayer | Using the FusionTablesLayer, you can display data on a Google Map
Also check out FusionTablesLayer Builder, which generates all the code necessary to include a Google Map with a Fusion Table Layer on your own website. |
FusionTablesLayer, Google Maps API |
JavaScript – Google Chart Tools | Using the Google Chart Tools, you can request data from Fusion Tables to use in visualizations or to display directly in an HTML page. Note: responses are limited to 500 rows of data. | Google Chart Tools |
Google Fusion Tables is dedicated to providing code examples that illustrate typical uses, best practices, and really cool tricks. If you do something with the Google Fusion Tables API that you think would be interesting to others, please contact us at googletables-feedback@google.com about adding your code to our Examples page.
Updated-You can use Google Fusion Tables from within R from http://andrei.lopatenko.com/rstat/fusion-tables.R
ft.connect <- function(username, password) { url = "https://www.google.com/accounts/ClientLogin"; params = list(Email = username, Passwd = password, accountType="GOOGLE", service= "fusiontables", source = "R_client_API") connection = postForm(uri = url, .params = params) if (length(grep("error", connection, ignore.case = TRUE))) { stop("The wrong username or password") return ("") } authn = strsplit(connection, "\nAuth=")[[c(1,2)]] auth = strsplit(authn, "\n")[[c(1,1)]] return (auth) } ft.disconnect <- function(connection) { } ft.executestatement <- function(auth, statement) { url = "http://tables.googlelabs.com/api/query" params = list( sql = statement) connection.string = paste("GoogleLogin auth=", auth, sep="") opts = list( httpheader = c("Authorization" = connection.string)) result = postForm(uri = url, .params = params, .opts = opts) if (length(grep("<HTML>\n<HEAD>\n<TITLE>Parse error", result, ignore.case = TRUE))) { stop(paste("incorrect sql statement:", statement)) } return (result) } ft.showtables <- function(auth) { url = "http://tables.googlelabs.com/api/query" params = list( sql = "SHOW TABLES") connection.string = paste("GoogleLogin auth=", auth, sep="") opts = list( httpheader = c("Authorization" = connection.string)) result = getForm(uri = url, .params = params, .opts = opts) tables = strsplit(result, "\n") tableid = c() tablename = c() for (i in 2:length(tables[[1]])) { str = tables[[c(1,i)]] tnames = strsplit(str,",") tableid[i-1] = tnames[[c(1,1)]] tablename[i-1] = tnames[[c(1,2)]] } tables = data.frame( ids = tableid, names = tablename) return (tables) } ft.describetablebyid <- function(auth, tid) { url = "http://tables.googlelabs.com/api/query" params = list( sql = paste("DESCRIBE", tid)) connection.string = paste("GoogleLogin auth=", auth, sep="") opts = list( httpheader = c("Authorization" = connection.string)) result = getForm(uri = url, .params = params, .opts = opts) columns = strsplit(result,"\n") colid = c() colname = c() coltype = c() for (i in 2:length(columns[[1]])) { str = columns[[c(1,i)]] cnames = strsplit(str,",") colid[i-1] = cnames[[c(1,1)]] colname[i-1] = cnames[[c(1,2)]] coltype[i-1] = cnames[[c(1,3)]] } cols = data.frame(ids = colid, names = colname, types = coltype) return (cols) } ft.describetable <- function (auth, table_name) { table_id = ft.idfromtablename(auth, table_name) result = ft.describetablebyid(auth, table_id) return (result) } ft.idfromtablename <- function(auth, table_name) { tables = ft.showtables(auth) tableid = tables$ids[tables$names == table_name] return (tableid) } ft.importdata <- function(auth, table_name) { tableid = ft.idfromtablename(auth, table_name) columns = ft.describetablebyid(auth, tableid) column_spec = "" for (i in 1:length(columns)) { column_spec = paste(column_spec, columns[i, 2]) if (i < length(columns)) { column_spec = paste(column_spec, ",", sep="") } } mdata = matrix(columns$names, nrow = 1, ncol = length(columns), dimnames(list(c("dummy"), columns$names)), byrow=TRUE) select = paste("SELECT", column_spec) select = paste(select, "FROM") select = paste(select, tableid) result = ft.executestatement(auth, select) numcols = length(columns) rows = strsplit(result, "\n") for (i in 3:length(rows[[1]])) { row = strsplit(rows[[c(1,i)]], ",") mdata = rbind(mdata, row[[1]]) } output.frame = data.frame(mdata[2:length(mdata[,1]), 1]) for (i in 2:ncol(mdata)) { output.frame = cbind(output.frame, mdata[2:length(mdata[,i]),i]) } colnames(output.frame) = columns$names return (output.frame) } quote_value <- function(value, to_quote = FALSE, quote = "'") { ret_value = "" if (to_quote) { ret_value = paste(quote, paste(value, quote, sep=""), sep="") } else { ret_value = value } return (ret_value) } converttostring <- function(arr, separator = ", ", column_types) { con_string = "" for (i in 1:(length(arr) - 1)) { value = quote_value(arr[i], column_types[i] != "number") con_string = paste(con_string, value) con_string = paste(con_string, separator, sep="") } if (length(arr) >= 1) { value = quote_value(arr[length(arr)], column_types[length(arr)] != "NUMBER") con_string = paste(con_string, value) } } ft.exportdata <- function(auth, input_frame, table_name, create_table) { if (create_table) { create.table = "CREATE TABLE " create.table = paste(create.table, table_name) create.table = paste(create.table, "(") cnames = colnames(input_frame) for (columnname in cnames) { create.table = paste(create.table, columnname) create.table = paste(create.table, ":string", sep="") if (columnname != cnames[length(cnames)]){ create.table = paste(create.table, ",", sep="") } } create.table = paste(create.table, ")") result = ft.executestatement(auth, create.table) } if (length(input_frame[,1]) > 0) { tableid = ft.idfromtablename(auth, table_name) columns = ft.describetablebyid(auth, tableid) column_spec = "" for (i in 1:length(columns$names)) { column_spec = paste(column_spec, columns[i, 2]) if (i < length(columns$names)) { column_spec = paste(column_spec, ",", sep="") } } insert_prefix = "INSERT INTO " insert_prefix = paste(insert_prefix, tableid) insert_prefix = paste(insert_prefix, "(") insert_prefix = paste(insert_prefix, column_spec) insert_prefix = paste(insert_prefix, ") values (") insert_suffix = ");" insert_sql_big = "" for (i in 1:length(input_frame[,1])) { data = unlist(input_frame[i,]) values = converttostring(data, column_types = columns$types) insert_sql = paste(insert_prefix, values) insert_sql = paste(insert_sql, insert_suffix) ; insert_sql_big = paste(insert_sql_big, insert_sql) if (i %% 500 == 0) { ft.executestatement(auth, insert_sql_big) insert_sql_big = "" } } ft.executestatement(auth, insert_sql_big) } }
R Node is a great web interface to R.
http://squirelove.net/r-node/doku.php
R-Online https://user.cs.tu-berlin.de/~ulfi/cgi-bin/r-online/r-online.cgi(The official FAQ seems outdated )
http://sysbio.mrc-bsu.cam.ac.uk/Rwui/
http://cran.r-project.org/web/packages/R.rsp/index.html
http://www.rforge.net/doc/packages/Rserve/00Index.html
http://rpad.googlecode.com/svn-history/r76/Rpad_homepage/index.html
JSS paper Citation. CGIwithR: Facilities for processing Web forms using R. Journal of Statistical Software, 8(10), pp. 1-8, 2003.
A lecture on aspects of using CGI
http://biostat.mc.vanderbilt.edu/rapache/
Wessa, P. (2011), Free Statistics Software, Office for Research Development and Education,
version 1.1.23-r6, URL http://www.wessa.net/
submit
button to submit the data. The procedure selection window is used to start the analysis, which uses the current values in the data window.To make an interactive GUI in gWidgets can be as easy as creating the following script:
w <- gwindow(’simple interactive GUI with one button’, visible=FALSE)
g <- ggroup(cont=w)
b <- gbutton(’click me’, cont=g, handler=function(h,...) {
gmessage(’hello world’, parent=b)
})
visible(w) <- TRUE
A big and slightly outdated resource page from (which I used for some find and seek of resources)
http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/StatCompCourse
AND
The famous site at http://www.yeroon.net/ggplot2/ (but no sharing of this site’s source code ,sigh!)
Thats all for now- but watch this space its exciting (to watch AND code) –
This page lists code editors (or IDE)
https://rforanalytics.wordpress.com/code-enhancers-for-r/
https://rforanalytics.wordpress.com/graphical-user-interfaces-for-r/
https://rforanalytics.wordpress.com/odbc-databases-for-r/
Yes Opera is a browser but you may as well call it an OS. With an uncluttered design, some mind bending Opera Unite Peer to Peer features (in a browser!) withhttp://unite.opera.com/applications/, and nifty widgets- try singing some Opera. I really dont know how browsers make money, especially since they are suing each other all the time, but well- heres to more choice – if you don’t want a corporation owned browser lusting to sell your leaked privacy data to Don Draper- Opera is a good choice- much better than Sea Monkey and the Fox .
I really liked the option to make my own web server in 2 clicks,and share stuff. The bit trorrent support is really nice but I wonder if there was any Scandinavian brotherly ports in bit torrent sharing 😉 , me hearties