Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with plotEqn #41

Closed
aoandrade opened this issue Aug 22, 2021 · 1 comment
Closed

Problem with plotEqn #41

aoandrade opened this issue Aug 22, 2021 · 1 comment

Comments

@aoandrade
Copy link

I am trying to use the package matlib, however see the type of error I am getting.

If necessary, you can improve the package.

library(matlib) # use the package

A <- matrix(c(0.1, 0.3, 0.5, 0.9, 0.7,0.5), 3, 2)

b <- c(-0.3,-0.1, 0.1)

showEqn(A, b)

plotEqn(A,b)

Solve(A, b) # unique solution

plotEqn(A,b)

0.x[1] + 0.9*x[2] = -0.3

0.3x[1] + 0.7x[2] = -0.1

0.5x[1] + 0.5x[2] = 0.1

Error in parse(text = sub("=", "==", labels[i])) :

:1:5: unexpected symbol

1: 0.x

    ^
@philchalmers
Copy link
Collaborator

I ran your code with the latest version of the package, however I do not see the issue.

library(matlib)
A <- matrix(c(0.1, 0.3, 0.5, 0.9, 0.7,0.5), 3, 2)
b <- c(-0.3,-0.1, 0.1)
showEqn(A, b)
#> 0.1*x1 + 0.9*x2  =  -0.3 
#> 0.3*x1 + 0.7*x2  =  -0.1 
#> 0.5*x1 + 0.5*x2  =   0.1
plotEqn(A,b)
#> 0.1*x[1] + 0.9*x[2]  =  -0.3 
#> 0.3*x[1] + 0.7*x[2]  =  -0.1 
#> 0.5*x[1] + 0.5*x[2]  =   0.1

Solve(A, b) # unique solution
#> x1    =   0.6 
#>   x2  =  -0.4 
#>    0  =     0
plotEqn(A,b)
#> 0.1*x[1] + 0.9*x[2]  =  -0.3 
#> 0.3*x[1] + 0.7*x[2]  =  -0.1 
#> 0.5*x[1] + 0.5*x[2]  =   0.1

It's possible this has to do with an earlier version of the package, so feel free to update from Github directly or wait until the next CRAN release.

Created on 2022-12-06 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants