Create line chart using R by reading data from an excel file

Viewed 18

I am in need of your help.
I'm trying to generate a line chart in R using data from 2 excel files.
The graph I'm trying to generate is similar to the one shown below

Grafic

The data presented in this excel image is an example and has more than 1000 lines, but I only need the first 100 of each file Excel file example

Thanks for your help

excel

1 Answers

After downloading the .xlt file from your public Onedrive account, I first looked at it with my Linux version of LibreOffice to make sure there was something there, then I did this:

> library(haven)
> help(pac=haven)  # drats I thought haven did excel, apparently not
> library(readxl)
> help(pac=readxl)   # read some of the help pages to see if an xlt format would be ok
dat <- read_excel("~/Downloads/teste.xlt") # no confirmation that it would be,
     # so experimented
                                                                                                                  
 str(dat)
#----
tibble [1,001 × 2] (S3: tbl_df/tbl/data.frame)
 $ Tempo: chr [1:1001] "0" "0.1" "0.2" "0.3" ...
 $ Prob : chr [1:1001] "0.0" "0.095188" "0.1813153" "0.2592441" ...

# So success and now to plot with base graphics, of course.

 plot(Tempo~Prob, dat[1:100, ])
 plot(Prob~Tempo, dat[1:100, ])

enter image description here

Oh, wait. You wanted a line with small points. Then do this:

png(); plot(Prob~Tempo, dat[seq(1,101, by=5), ], type ="b", cex=0.2, col="green"); dev.off()

enter image description here

Related