need finite 'ylim' values-error

后端 未结 1 783
广开言路
广开言路 2021-01-25 17:50

I want to show big numbers in a plot in r. but I get this error:

my numbers are:

[1] \"9,02E+11\" \"9,02E+11\" \"9,02E+11\" \"9,02E+11\" \"9,02E+11\" \"9         


        
相关标签:
1条回答
  • 2021-01-25 18:21

    Try this:

    plot(sapply(dataliste, function(x)gsub(",", ".", x)))
    

    As Roman Luštrik pointed out, you most likely have characters in your data. You can generally plot them or convert them with as.numeric. However, since you have a , instead of a . in your strings, the conversion to numeric fails. Example:

    > as.numeric("9,02E+11")
    [1] NA
    Warning message:
    NAs introduced by coercion 
    > as.numeric("9.02E+11")
    [1] 9.02e+11
    

    With gsub, as above, you can substitute the , for a . for each number and plotting should work.

    0 讨论(0)
提交回复
热议问题