[R] read .csv file and plot a graph

Jim Lemon jim at bitwrit.com.au
Sat May 4 06:56:39 CEST 2013


On 05/03/2013 11:49 PM, Vahe nr wrote:
> Hi all,
>
> I have a big .csv file (21Mb with 1000000 rows) it has this shape:
> x
> 1 NaN
> 2 NaN
> 3 0.23
>
> and so on.....
>
> So the first column has x as a header then row number, the second column
> contains values between -1,1 and NaN for empty values.
>
> What should I need to do is: create a new .csv file from this one excluding
> NaN values and plot a line graph using the new .csv file.
>
> Or can I use the old .csv file to plot a graph excluding NaN values.
>
Hi Vahe,
If you want to plot the line ignoring the NaN values, rather than having 
the line break at each NaN, use this:

vndat<-data.frame(1:10,
  x=c(-1,-0.6,-0.4,NaN,-0.2,0.2,0.4,NaN,0.6,0.8))
plot(vndat$x[complete.cases(vndat$x)],type="l")

Jim (the other one)



More information about the R-help mailing list