mydata <- mtcars install.packages("stargazer") #Use this to install it, do this only once library(stargazer) stargazer(mydata, type = "text", title="Descriptive statistics", digits=1, out="table1.txt") stargazer(mydatstargazer(mydata, type = "text", title="Descriptive statistics", digits=1, out="table1.txt", covariate.labels=c("Miles/(US)gallon","No. of cylinders","Displacement (cu.in.)", "Gross horsepower","Rear axle ratio","Weight (lb/1000)", "1/4 mile time","V/S","Transmission (0=auto, 1=manual)", "Number of forward gears","Number of carburetors")) a, type = "text", title="Descriptive statistics", digits=1, out="table1.txt", flip=TRUE) stargazer(mydata[c("mpg","hp","drat")], type = "text", title="Descriptive statistics/selected variables", digits=1, out="table2.txt") stargazer(mydata, title="Descriptive statistics", digits=1, out="table1.txt") mydata$fast <- as.numeric((mydata$mpg > 20.1)) #Creating a dummy variable 1 = fast car m1 <- lm(mpg ~ hp, data=mydata) m2 <- lm(mpg ~ hp + drat, data=mydata) m3 <- lm(mpg ~ hp + drat + factor(gear), data=mydata) m4 <- glm(fast ~ hp + drat + am, family=binomial(link="logit"), data=mydata) stargazer(m1, m2, m3, m4, type="text", dep.var.labels=c("Miles/(US) gallon","Fast car (=1)"), covariate.labels=c("Gross horsepower","Rear axle ratio","Four foward gears", "Five forward gears","Type of transmission (manual=1)"), out="models.txt")v