I find myself recreating nested frequency tables over and over again from articles using matrix and recreating tables (or sometimes giving up and using rep and making the full data set which is very time consuming. I'm looking for the fastest way (least code) to recreate this nested frequency table in R (I assume this is a question that many can benefit from).
gender female male
hs.grad race
no asian 3 4
black 5 10
white 17 11
yes asian 5 7
black 1 9
white 11 17
This was created using ftable if that's helpful.
Thank you in advance.
Do you mean something like this?
file = tempfile()
cat (text=' gender female male
hs.grad race
no asian 3 4
black 5 10
white 17 11
yes asian 5 7
black 1 9
white 11 17
', file=file)
ft = read.ftable(file)
Or
> read.ftable(textConnection(" gender female male
+ hs.grad race
+ no asian 3 4
+ black 5 10
+ white 17 11
+ yes asian 5 7
+ black 1 9
+ white 11 17"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With