Object 'myvariable' not found.But my variable exists if i run str(dataframe)












-5















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"])









share|improve this question

























  • 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











  • 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











  • 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
















-5















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"])









share|improve this question

























  • 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











  • 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











  • 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














-5












-5








-5








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"])









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 17:19









Naveen

920214




920214










asked Jan 1 at 11:19









Άγγελος Γ.Άγγελος Γ.

11




11













  • 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











  • 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











  • 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













  • 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













  • 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












1 Answer
1






active

oldest

votes


















0














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))





share|improve this answer
























  • 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













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
});


}
});














draft saved

draft discarded


















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









0














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))





share|improve this answer
























  • 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


















0














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))





share|improve this answer
























  • 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
















0












0








0







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))





share|improve this answer













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))






share|improve this answer












share|improve this answer



share|improve this answer










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





















  • 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






















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

Npm cannot find a required file even through it is in the searched directory