Object 'myvariable' not found.But my variable exists if i run str(dataframe)
I have the Mroz
dataframe and i am trying to get the median
of the inc
variable of people that are assigned as "no" and later as "yes" in the wc
variable. But it says that the object wc does not exist
although when i run str(Mroz)
it is written along with all the other variables.
str(Mroz)
mean(Mroz$inc[wc=="No"])
mean(Mroz$inc[wc=="Yes"])
r
add a comment |
I have the Mroz
dataframe and i am trying to get the median
of the inc
variable of people that are assigned as "no" and later as "yes" in the wc
variable. But it says that the object wc does not exist
although when i run str(Mroz)
it is written along with all the other variables.
str(Mroz)
mean(Mroz$inc[wc=="No"])
mean(Mroz$inc[wc=="Yes"])
r
Trymean(Mroz$inc[Mroz$wc=="No"])
formean
ormedian(Mroz$inc[Mroz$wc=="No"])
to get median
– Ronak Shah
Jan 1 at 11:25
I tried it but is says NaN
– Άγγελος Γ.
Jan 1 at 11:28
Usena.rm
argument,mean(Mroz$inc[Mroz$wc=="No"], na.rm = TRUE)
and same formedian
– Ronak Shah
Jan 1 at 11:30
It still says NaN
– Άγγελος Γ.
Jan 1 at 11:32
The wc variable take only yes or no so how can it be a number(cause from what i have seen nan stands for not a number)
– Άγγελος Γ.
Jan 1 at 11:33
add a comment |
I have the Mroz
dataframe and i am trying to get the median
of the inc
variable of people that are assigned as "no" and later as "yes" in the wc
variable. But it says that the object wc does not exist
although when i run str(Mroz)
it is written along with all the other variables.
str(Mroz)
mean(Mroz$inc[wc=="No"])
mean(Mroz$inc[wc=="Yes"])
r
I have the Mroz
dataframe and i am trying to get the median
of the inc
variable of people that are assigned as "no" and later as "yes" in the wc
variable. But it says that the object wc does not exist
although when i run str(Mroz)
it is written along with all the other variables.
str(Mroz)
mean(Mroz$inc[wc=="No"])
mean(Mroz$inc[wc=="Yes"])
r
r
edited Jan 1 at 17:19


Naveen
920214
920214
asked Jan 1 at 11:19


Άγγελος Γ.Άγγελος Γ.
11
11
Trymean(Mroz$inc[Mroz$wc=="No"])
formean
ormedian(Mroz$inc[Mroz$wc=="No"])
to get median
– Ronak Shah
Jan 1 at 11:25
I tried it but is says NaN
– Άγγελος Γ.
Jan 1 at 11:28
Usena.rm
argument,mean(Mroz$inc[Mroz$wc=="No"], na.rm = TRUE)
and same formedian
– Ronak Shah
Jan 1 at 11:30
It still says NaN
– Άγγελος Γ.
Jan 1 at 11:32
The wc variable take only yes or no so how can it be a number(cause from what i have seen nan stands for not a number)
– Άγγελος Γ.
Jan 1 at 11:33
add a comment |
Trymean(Mroz$inc[Mroz$wc=="No"])
formean
ormedian(Mroz$inc[Mroz$wc=="No"])
to get median
– Ronak Shah
Jan 1 at 11:25
I tried it but is says NaN
– Άγγελος Γ.
Jan 1 at 11:28
Usena.rm
argument,mean(Mroz$inc[Mroz$wc=="No"], na.rm = TRUE)
and same formedian
– Ronak Shah
Jan 1 at 11:30
It still says NaN
– Άγγελος Γ.
Jan 1 at 11:32
The wc variable take only yes or no so how can it be a number(cause from what i have seen nan stands for not a number)
– Άγγελος Γ.
Jan 1 at 11:33
Try
mean(Mroz$inc[Mroz$wc=="No"])
for mean
or median(Mroz$inc[Mroz$wc=="No"])
to get median– Ronak Shah
Jan 1 at 11:25
Try
mean(Mroz$inc[Mroz$wc=="No"])
for mean
or median(Mroz$inc[Mroz$wc=="No"])
to get median– Ronak Shah
Jan 1 at 11:25
I tried it but is says NaN
– Άγγελος Γ.
Jan 1 at 11:28
I tried it but is says NaN
– Άγγελος Γ.
Jan 1 at 11:28
Use
na.rm
argument, mean(Mroz$inc[Mroz$wc=="No"], na.rm = TRUE)
and same for median
– Ronak Shah
Jan 1 at 11:30
Use
na.rm
argument, mean(Mroz$inc[Mroz$wc=="No"], na.rm = TRUE)
and same for median
– Ronak Shah
Jan 1 at 11:30
It still says NaN
– Άγγελος Γ.
Jan 1 at 11:32
It still says NaN
– Άγγελος Γ.
Jan 1 at 11:32
The wc variable take only yes or no so how can it be a number(cause from what i have seen nan stands for not a number)
– Άγγελος Γ.
Jan 1 at 11:33
The wc variable take only yes or no so how can it be a number(cause from what i have seen nan stands for not a number)
– Άγγελος Γ.
Jan 1 at 11:33
add a comment |
1 Answer
1
active
oldest
votes
Your requirement: Need mean/median value of "inc" variable by the field in "wc" Column
For the above requirement, you can use below code
library(dplyr)
Mroz %>% group_by(wc) %>% summarise(mean(inc))
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
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%2f53995001%2fobject-myvariable-not-found-but-my-variable-exists-if-i-run-strdataframe%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
Your requirement: Need mean/median value of "inc" variable by the field in "wc" Column
For the above requirement, you can use below code
library(dplyr)
Mroz %>% group_by(wc) %>% summarise(mean(inc))
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
add a comment |
Your requirement: Need mean/median value of "inc" variable by the field in "wc" Column
For the above requirement, you can use below code
library(dplyr)
Mroz %>% group_by(wc) %>% summarise(mean(inc))
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
add a comment |
Your requirement: Need mean/median value of "inc" variable by the field in "wc" Column
For the above requirement, you can use below code
library(dplyr)
Mroz %>% group_by(wc) %>% summarise(mean(inc))
Your requirement: Need mean/median value of "inc" variable by the field in "wc" Column
For the above requirement, you can use below code
library(dplyr)
Mroz %>% group_by(wc) %>% summarise(mean(inc))
answered Jan 1 at 12:15


GhanshyamGhanshyam
238
238
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
add a comment |
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
Thank you very much it worked!Now i want to make a boxplot but when i write boxplot(Mroz$inc~wc,main="Income by age", it says object wc not found.It is the same problem again so what should i do now?(The variable wc is defined if i use the str command so i dont know what is it saying it is not found)
– Άγγελος Γ.
Jan 1 at 13:01
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%2f53995001%2fobject-myvariable-not-found-but-my-variable-exists-if-i-run-strdataframe%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
Try
mean(Mroz$inc[Mroz$wc=="No"])
formean
ormedian(Mroz$inc[Mroz$wc=="No"])
to get median– Ronak Shah
Jan 1 at 11:25
I tried it but is says NaN
– Άγγελος Γ.
Jan 1 at 11:28
Use
na.rm
argument,mean(Mroz$inc[Mroz$wc=="No"], na.rm = TRUE)
and same formedian
– Ronak Shah
Jan 1 at 11:30
It still says NaN
– Άγγελος Γ.
Jan 1 at 11:32
The wc variable take only yes or no so how can it be a number(cause from what i have seen nan stands for not a number)
– Άγγελος Γ.
Jan 1 at 11:33