importing data and getting colmeans


I have imported a txt data frame into rstudio using the read.table function and then created a subset of that data and want to get the colmeans but i get an error that says "Error in colMeans(data) : 'x' must be numeric" i dont know what that means because I am doing this and i have an example that i am reffering to and the code does not differ so Im so confused.

Very likely there are non numeric variables in your data frame, to help you solve this problem, can you provide a sample of your txt file?

thats how my data looks like in text

but they are all numeric so I am very confused

That is a screenshot, we can't copy from that to try to give you a working solution. I suspect that your variables are being treated as character vectors because of the comma in the number format but I can't be sure since you are not providing sample data, you can try converting them using as.numeric() function.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like

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