“…argument 4 matches multiple formal arguments” - 3D surface plot
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I can't get the scatter3D function to work in R. I would like to plot a surface but am unable to get the code to run although it is very simple to some I found online. I have tried reading the CRAN code documentation but I can't get anywhere. I would like my code to run.
Essentially there is a problem with some variable I am putting in but I can't see where. I think it might be hidden inside a function and the error message is not actually for me.
Any help would be appreciated.
Code:
library("plot3D")
w <- 1:100
sigma <- 5
x <- w + rnorm(w, w, 2*sigma)
y <- w + rnorm(w, w, sigma)
z<- w + rnorm(w, w, 3*sigma)
a <- c()
for (i in 1:10){
a <- c(a, rep(10*i, times = 10))
}
b <- rep(seq(10, 100, 10), times = 10)
ratio = 0.4
d = ratio*a + (1 - ratio)*b + rnorm(100, 0, 10)
fit <- lm(d ~ a + b)
grid.lines = 26
a.pred <- seq(min(a), max(a), length.out = grid.lines)
b.pred <- seq(min(b), max(b), length.out = grid.lines)
ab <- expand.grid(a = a.pred, b = b.pred)
d.pred <- matrix(predict(fit, newdata = ab),
nrow = grid.lines, ncol = grid.lines)
fitpoints <- predict(fit)
scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(a=a.pred, b=b.pred, d=d.pred,
facets = F, fit = fitpoints))
Error message:
Error in addimg(poly = NULL, plist = plist, a = c(10, 13.6, 17.2, 20.8, :
argument 4 matches multiple formal arguments
r plot 3d surface
add a comment |
I can't get the scatter3D function to work in R. I would like to plot a surface but am unable to get the code to run although it is very simple to some I found online. I have tried reading the CRAN code documentation but I can't get anywhere. I would like my code to run.
Essentially there is a problem with some variable I am putting in but I can't see where. I think it might be hidden inside a function and the error message is not actually for me.
Any help would be appreciated.
Code:
library("plot3D")
w <- 1:100
sigma <- 5
x <- w + rnorm(w, w, 2*sigma)
y <- w + rnorm(w, w, sigma)
z<- w + rnorm(w, w, 3*sigma)
a <- c()
for (i in 1:10){
a <- c(a, rep(10*i, times = 10))
}
b <- rep(seq(10, 100, 10), times = 10)
ratio = 0.4
d = ratio*a + (1 - ratio)*b + rnorm(100, 0, 10)
fit <- lm(d ~ a + b)
grid.lines = 26
a.pred <- seq(min(a), max(a), length.out = grid.lines)
b.pred <- seq(min(b), max(b), length.out = grid.lines)
ab <- expand.grid(a = a.pred, b = b.pred)
d.pred <- matrix(predict(fit, newdata = ab),
nrow = grid.lines, ncol = grid.lines)
fitpoints <- predict(fit)
scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(a=a.pred, b=b.pred, d=d.pred,
facets = F, fit = fitpoints))
Error message:
Error in addimg(poly = NULL, plist = plist, a = c(10, 13.6, 17.2, 20.8, :
argument 4 matches multiple formal arguments
r plot 3d surface
add a comment |
I can't get the scatter3D function to work in R. I would like to plot a surface but am unable to get the code to run although it is very simple to some I found online. I have tried reading the CRAN code documentation but I can't get anywhere. I would like my code to run.
Essentially there is a problem with some variable I am putting in but I can't see where. I think it might be hidden inside a function and the error message is not actually for me.
Any help would be appreciated.
Code:
library("plot3D")
w <- 1:100
sigma <- 5
x <- w + rnorm(w, w, 2*sigma)
y <- w + rnorm(w, w, sigma)
z<- w + rnorm(w, w, 3*sigma)
a <- c()
for (i in 1:10){
a <- c(a, rep(10*i, times = 10))
}
b <- rep(seq(10, 100, 10), times = 10)
ratio = 0.4
d = ratio*a + (1 - ratio)*b + rnorm(100, 0, 10)
fit <- lm(d ~ a + b)
grid.lines = 26
a.pred <- seq(min(a), max(a), length.out = grid.lines)
b.pred <- seq(min(b), max(b), length.out = grid.lines)
ab <- expand.grid(a = a.pred, b = b.pred)
d.pred <- matrix(predict(fit, newdata = ab),
nrow = grid.lines, ncol = grid.lines)
fitpoints <- predict(fit)
scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(a=a.pred, b=b.pred, d=d.pred,
facets = F, fit = fitpoints))
Error message:
Error in addimg(poly = NULL, plist = plist, a = c(10, 13.6, 17.2, 20.8, :
argument 4 matches multiple formal arguments
r plot 3d surface
I can't get the scatter3D function to work in R. I would like to plot a surface but am unable to get the code to run although it is very simple to some I found online. I have tried reading the CRAN code documentation but I can't get anywhere. I would like my code to run.
Essentially there is a problem with some variable I am putting in but I can't see where. I think it might be hidden inside a function and the error message is not actually for me.
Any help would be appreciated.
Code:
library("plot3D")
w <- 1:100
sigma <- 5
x <- w + rnorm(w, w, 2*sigma)
y <- w + rnorm(w, w, sigma)
z<- w + rnorm(w, w, 3*sigma)
a <- c()
for (i in 1:10){
a <- c(a, rep(10*i, times = 10))
}
b <- rep(seq(10, 100, 10), times = 10)
ratio = 0.4
d = ratio*a + (1 - ratio)*b + rnorm(100, 0, 10)
fit <- lm(d ~ a + b)
grid.lines = 26
a.pred <- seq(min(a), max(a), length.out = grid.lines)
b.pred <- seq(min(b), max(b), length.out = grid.lines)
ab <- expand.grid(a = a.pred, b = b.pred)
d.pred <- matrix(predict(fit, newdata = ab),
nrow = grid.lines, ncol = grid.lines)
fitpoints <- predict(fit)
scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(a=a.pred, b=b.pred, d=d.pred,
facets = F, fit = fitpoints))
Error message:
Error in addimg(poly = NULL, plist = plist, a = c(10, 13.6, 17.2, 20.8, :
argument 4 matches multiple formal arguments
r plot 3d surface
r plot 3d surface
asked Nov 23 '18 at 14:24
stuart stevensonstuart stevenson
1083
1083
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I think you need to call x, y, and z-axis:
# scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(x=a.pred, y=b.pred, z=d.pred,
facets = F, fit = fitpoints))
This worked in my case.
Comment concerning bugfixing:
- Run your code line by line (RStudio Ctrl + Enter). Then you realize that your
scatter3D
is the problem. - Remove arguments until the command works. In your case this suggested that
surf = list(...)
was the problem.
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448446%2fargument-4-matches-multiple-formal-arguments-3d-surface-plot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you need to call x, y, and z-axis:
# scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(x=a.pred, y=b.pred, z=d.pred,
facets = F, fit = fitpoints))
This worked in my case.
Comment concerning bugfixing:
- Run your code line by line (RStudio Ctrl + Enter). Then you realize that your
scatter3D
is the problem. - Remove arguments until the command works. In your case this suggested that
surf = list(...)
was the problem.
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
add a comment |
I think you need to call x, y, and z-axis:
# scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(x=a.pred, y=b.pred, z=d.pred,
facets = F, fit = fitpoints))
This worked in my case.
Comment concerning bugfixing:
- Run your code line by line (RStudio Ctrl + Enter). Then you realize that your
scatter3D
is the problem. - Remove arguments until the command works. In your case this suggested that
surf = list(...)
was the problem.
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
add a comment |
I think you need to call x, y, and z-axis:
# scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(x=a.pred, y=b.pred, z=d.pred,
facets = F, fit = fitpoints))
This worked in my case.
Comment concerning bugfixing:
- Run your code line by line (RStudio Ctrl + Enter). Then you realize that your
scatter3D
is the problem. - Remove arguments until the command works. In your case this suggested that
surf = list(...)
was the problem.
I think you need to call x, y, and z-axis:
# scatter plot with regression plane
scatter3D(a,b,d, pch = 18, cex = 2,
theta = 20, phi = 20,
surf = list(x=a.pred, y=b.pred, z=d.pred,
facets = F, fit = fitpoints))
This worked in my case.
Comment concerning bugfixing:
- Run your code line by line (RStudio Ctrl + Enter). Then you realize that your
scatter3D
is the problem. - Remove arguments until the command works. In your case this suggested that
surf = list(...)
was the problem.
edited Nov 23 '18 at 15:59
answered Nov 23 '18 at 15:04
ChristophChristoph
3,05222044
3,05222044
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
add a comment |
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
Thank you Christoph. That was not clear in the example I found.
– stuart stevenson
Nov 23 '18 at 15:52
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
You're welcome! See my edit...
– Christoph
Nov 23 '18 at 15:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448446%2fargument-4-matches-multiple-formal-arguments-3d-surface-plot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown