I use Medicaid1986 data to analyze in AER package in R. But when I want to print number of rows and columns with nrow() and ncol(), it returns as NULL. how can I fix it?
CodePudding user response:
Dont assign the data in an object. Just do
data("Medicaid1986")
nrow(Medicaid1986)
#[1] 996
ncol(Medicaid1986)
#[1] 14
If you want to change its name, do it after you load the data, i.e.
data("Medicaid1986")
df <- Medicaid1986
If you do it your way, it returns a single value which is the string of the name,
medicaid1986 <- data("Medicaid1986")
medicaid1986
[1] "Medicaid1986"
CodePudding user response:
Maybe your data is a vector. You need to use NCOL() and NROW() for a vector.