1 |
file |
|
tfile |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (file, tfile = tempfile())
{
help = "\n sasin reads a .csv file created by SAS with\n ODS CSV FILE = 'file';\n < SAS procedure statements >\n ODS CSV CLOSE;\n The tables produced by SAS are elements in the list\n returned by sasin.\n "
todf <- function(ll) {
if (length(ll) < 3)
return(character(0))
if (length(ll) == 3)
return(ll[2])
cat(ll[2], "\n", file = tfile)
for (ii in 3:(length(ll) - 1)) {
cat(ll[ii], "\n", file = tfile, append = T)
}
df <- read.csv(tfile, header = F)
if (!any(sapply(df, is.numeric)))
df <- read.csv(tfile)
df
}
readin <- scan(file, what = "", sep = "\n", blank.lines.skip = F)
blanks <- which(readin == "")
head.pos <- c(1, 1 + head(blanks, -1))
heads <- gsub("\"|,", "", readin[head.pos])
reps <- diff(c(head.pos, 1 + length(readin)))
heads <- rep(heads, reps)
readin <- split(readin, heads)
readin <- lapply(readin, todf)
readin
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.