Error Message: could not find function "Matrix"

Hi. I created a matrix function with a for loop by using my R Markdown. It worked just fine if I run the chunk, however, when I knit the file, I received the following error message:

Error in Matrix(0, N, 1) : could not find function "Matrix"
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted

Here is the code which has error:

N = 717
p = 2

date1 = 1:N
Y = Matrix(0,N,1)
for (i in 1:N){
  Y[i]=gas[i,4]
  }

Can anyone give me some hints? Thank you in advance!

Hi,
I saw this post from twitter tidyverse account and i create a account and im here :d

Bc there is no function like “Matrix”, you must write “matrix”.
Capital letters cant be used with functions generally.

Have a good day.

1 Like

Welcome and thank you so much!
That was me being dumb and it became smooth when I switched to lowercase!

1 Like

No, its related to habits. Other languages generally use capital letters at the begining of the functions. Nowadays i am learning phython and i eather have some problems usage of letters :grinning:

Using R is really easy and fun. Enjoy with your work :grinning:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.