R: load R table or csv file with the textconnection command -
in previous message convert table matrix column names
i want use same approach csv table or table in r. mind teach me how modify first command line?
x <- read.table(textconnection(' models cores time 4 1 0.000365 4 2 0.000259 4 3 0.000239 4 4 0.000220 8 1 0.000259 8 2 0.000249 8 3 0.000251 8 4 0.000258' ), header=true) library(reshape) cast(x, models ~ cores) should use following data.csv file
x <- read.csv(textconnection("data.csv"), header=true) should use following r table named xyz
x <- xyz(textconnection(xyz), header=true) is must have textconnection using cast command?
thank you.
several years later...
read.table , derivatives read.csv have text argument, don't need mess around textconnections directly anymore.
read.table(text = " x y z 1 1.9 'a' 2 0.6 'b' ", header = true) the main use textconnection when people ask questions on dump data onscreen, rather writing code let answerers generate themselves. example,
blah blah blah i'm stuck here data plz omg
x y z
1 1.9 'a'
2 0.6 'b'
etc.
in case can copy text screen , wrap in call textconnection, so:
the_data <- read.table(tc <- textconnection("x y z 1 1.9 'a' 2 0.6 'b'"), header = true); close(tc) it nicer when questioners provide code, this:
the_data <- data.frame(x = 1:2, b = c(2.9, 0.6), c = letters[1:2]) when using own data, shouldn't ever need use textconnection.
my_data <- read.csv("my data file.csv") should suffice.
Comments
Post a Comment