Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Error in sum(x) : invalid 'type' (character) of argument

I'm new to R and this is a simple question that I didn't find answered anywhere else so I'm asking it here.

I'm importing a plain txt file named intron that contains a simple list of numbers 19000 19750 11670 12310 1870 38490 20200 16380 127890 12500 700 36900

intron = scan("intron.txt", what ="character")

All I want to do is find the sum and mean

When I sum I get this error: Error in sum(intron) : invalid 'type' (character) of argument

I have tried changing what = to no avail

When I try to calculate the mean I get this error:

mean(intron)
[1] NA
Warning message:
In mean.default(intron) : argument is not numeric or logical: returning NA

When I plug the numbers in at the terminal, mean and sum work fine but when I read in a file I get problems. I assume there is something I don't understand about reading in files.

However, I can calculate variance and standard variation of the imported file.

Thanks for your help

Comments