'Replicating table without the dataset

I am supposed to replicate a table in r. the table summarizes OLS regressors which are a result of the analysis on one dataset. I do not have the dataset but am supposed to replicate the table. this table is going to be used in a project when the survey phase is completed.



Solution 1:[1]

I'm going to assume you just want to build a table in R, rather than reproduce the OLS results based on some other information like the mean and variability of the data.

For each column you can build a list, or vector, using the c function:

regressors <- c("sunshine","rainfall","wind")
r2 <- c(0.1, 0.2, 0.3)

I've invented some data here, but you would fill the numbers/words in based on the table you're trying to replicate.

You can then build these into a table using the data.frame function, where you specify the names of the columns, and then point to the previously built lists:

table <- data.frame(regressors = regressors,
                    r2 = r2)

Or, you can do it all in one go, like this:

table <- data.frame(regressors = c("sunshine","rainfall","wind"),
                    r2 = c(0.1, 0.2, 0.3))

Alternatively, you could just type out the table into a program like Excel, save the worksheet as a csv file, then read it into R using read.csv:

table <- read.csv("path_to_your_csv_file.csv")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1