1

So I am currently doing a CES function estimation using the micEconCES package in R. I want to incorporate the outputs of the estimation into my latex file, but I cant seem to get it to work. This is the simplified version in R. I want it to look something like this

enter image description here

This is the code I am using in R. If I type in the code step by step in R then I get the wanted output, but if incorporate it into the Rnw file I get error messages.

\documentclass{article}
\begin{document}

#starting the R code

<<>>=

#reading in my data set from excel and changing a couple columns to 
numeric

DATA_FOR_2<- read_excel("~/Documents/DATA FOR  2.xlsx", col_types =
c("text", "text", "text","text", "text", "numeric", "numeric", 
"numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
"numeric", "numeric", "numeric", "numeric", "numeric", "numeric", 
"numeric", "numeric"))

#cutting out some unneeded rows

mydata <- DATA_FOR_2[-c(46:62), ]

#using the micEconCES code to do the Kmenta approximation

cesKmenta <- cesEst( yName = "gddp", xNames = c( "capiital", "labora" 
), data = mydata, method = "Kmenta", vrs = TRUE )

#calling summary stats

summary(cesKmenta)

#plotting the results

compPlot ( mydata$gddp, fitted( cesKmenta ), xlab = "actual values",
ylab = "fitted values" )
@

\end{document}

But when I compile this code as a PDF I get the error message:

DATA_FOR_2<- read_excel("~/Documents/DATA FOR  2.xlsx", col_types = c("text", "text", "text","text", "text", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))## Error in eval(expr, envir, enclos):  konnte Funktion "readexcel"nicht finden

mydata <- DATA_FOR_2[-c(46:62), ]## Error in eval(expr, envir, enclos):  Objekt 'DATAFOR2' nicht gefunden
cesKmenta <- cesEst( yName = "gddp", xNames = c( "capiital", "labora" ), data = mydata, method = "Kmenta", vrs = TRUE )## Error in eval(expr, envir, enclos):  konnte Funktion "cesEst" nicht finden

summary(cesKmenta)## Error in summary(cesKmenta):  Objekt 'cesKmenta' nicht gefunden

compPlot ( mydata$gddp, fitted( cesKmenta ), xlab = "actual values",ylab = "fitted values" )## Error in eval(expr, envir, enclos):  konnte Funktion "compPlot"nicht finden1

What am I doing wrong?

1 Answer 1

1

You probably forgot to load the library for the function read_excel. You have a clear error message in the first line:

konnte Funktion "readexcel"nicht finden

You have to add library(readxl) (if it is the package name) in your document. You could add an extra chunk of code after %starting the R code an load all the libraries you need for the document in one place

<<Load library>>
library(readxl)
# Other packages
@

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .