Suppose I have the following table (as a Tex file)
\begin{table}[]
\centering
\begin{tabular}{@{}llll@{}}
\toprule
variables & group a & group b & diff \\ \midrule
x & a11 & b12 & d13 \\
y & a21 & b22 & d23 \\
z & a31 & b32 & d33 \\ \bottomrule
\end{tabular}
\end{table}
Is there any package or way to open this as a dataframe in R?
Thanks in advance.
CodePudding user response:
You can use read.delim
directly:
> dat <- read.delim(text="variables & group a & group b & diff \\
x & a11 & b12 & d13 \\
y & a21 & b22 & d23 \\
z & a31 & b32 & d33 \\ ", sep="&", comment.char = "\\")
> dat
variables group.a group.b diff
1 x a11 b12 d13
2 y a21 b22 d23
3 z a31 b32 d33
Just remove \midrule
and \bottomrule