[R] Need help with plotting the graph

Prasad Joshi prasadjoshi124 at gmail.com
Tue Oct 8 02:24:23 CEST 2013


On Tue, Oct 8, 2013 at 1:48 AM, David Carlson <dcarlson at tamu.edu> wrote:
> First. You should update R to the latest version, 3.0.2.
>
Hello David,

Thanks a lot for your reply. I will update R.

>
> Third. Use dput(df) and send the output to the mailing list. A
> data frame usually consists of several vectors, not several
> lists. It might be necessary to explain how you created or
> obtained df.
>

The data is generated by reading the CSV files. The source code is as below
==============================================================
get_iops <- function(x) {
  good <- complete.cases(x$Read.IOps)
  mean(x$Read.IOps[good])
}

get_mbs <- function(x) {
  good <- complete.cases(x$Read.MBps)
  mean(x$Read.MBps[good])
}

lappend <- function(lst, obj) {
  lst[[length(lst)+1]] <- obj
  return(lst)
}

result <- list()

disk <- "naa.5000a7203007ed8f"
vmfs3_eager = read.csv("VMFS3-Thick-Eager.csv")
iops <- get_iops(vmfs3_eager)
bw <- get_mbs(vmfs3_eager)
x <- list(disk = disk, vmfs = 3, vmdk = "eager", IOPS = iops, BW = bw)
result <- lappend(result, x)

# I read 6 such CSV files
...
...

df <- as.data.frame(do.call(rbind, result))
==============================================================

> dput(df)
structure(list(disk = list("naa.5000a7203007ed8f", "naa.5000a7203007ed8f",
    "naa.5000a7203007ed8f", "naa.5000a7203007ed8f", "naa.5000a720300895c4",
    "naa.5000a720300895c4", "naa.5000a720300895c4", "naa.5000a720300895c4"),
    vmfs = list(3, 3, 5, 5, 3, 3, 5, 5), vmdk = list("eager",
        "lazy", "eager", "lazy", "eager", "lazy", "eager", "lazy"),
    IOPS = list(16886.766301, 44623.145983, 16767.526886, 45891.547436,
        16794.495655, 45289.670722, 16603.198764, 46092.4011),
    BW = list(65.963931, 174.309164, 65.498152, 179.263857, 65.603499,
        176.912776, 64.856245, 180.048442)), .Names = c("disk",
"vmfs", "vmdk", "IOPS", "BW"), row.names = c(NA, -8L), class = "data.frame")

> df
                  disk vmfs  vmdk     IOPS       BW
1 naa.5000a7203007ed8f    3 eager 16886.77 65.96393
2 naa.5000a7203007ed8f    3  lazy 44623.15 174.3092
3 naa.5000a7203007ed8f    5 eager 16767.53 65.49815
4 naa.5000a7203007ed8f    5  lazy 45891.55 179.2639
5 naa.5000a720300895c4    3 eager  16794.5  65.6035
6 naa.5000a720300895c4    3  lazy 45289.67 176.9128
7 naa.5000a720300895c4    5 eager  16603.2 64.85625
8 naa.5000a720300895c4    5  lazy  46092.4 180.0484


I used lists since, I wanted to avoid the compulsory coercion that
happens in vectors. I though using numbers for IOPS and BW would be
better for plotting the graphs.

> Second. What commands have you tried and what error messages did
> you receive?

I wanted to plot the graph of BW or IOPS against combination of
disk+vmfs+vmdk. For example: if I take the first row from above df
dataframe, I would like graph to contain BW 65 on Y axis and X axis
caption would be "naa.5000a7203007ed8f-3-eager".

I tried to plot graph using hist, plot, boxplot -- however I could not
find a way to specify multiple values for X axis.

I will look forward for your reply.

Thanks and Regards,
Prasad


> -------------------------------------
> David L Carlson
> Associate Professor of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Prasad Joshi
> Sent: Monday, October 7, 2013 5:03 AM
> To: r-help at r-project.org
> Subject: [R] Need help with plotting the graph
>
> Hello All,
>
> The version of R I am using is as follows
>> version
>                _
> platform       x86_64-pc-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status
> major          2
> minor          14.1
> year           2011
> month          12
> day            22
> svn rev        57956
> language       R
> version.string R version 2.14.1 (2011-12-22)
>
>
> I just few days back started using R for basic statistical
> analysis. I
> want to plot the graph of following information
>
>
>> df
>                   disk vmfs  vmdk     IOPS       BW
> 1 naa.5000a7203007ed8f    3 eager 16886.77 65.96393
> 2 naa.5000a7203007ed8f    3  lazy 44623.15 174.3092
> 3 naa.5000a7203007ed8f    5 eager 16767.53 65.49815
> 4 naa.5000a7203007ed8f    5  lazy 45891.55 179.2639
>
>> str(df)
> 'data.frame':    4 obs. of  5 variables:
>  $ disk:List of 4
>   ..$ : chr "naa.5000a7203007ed8f"
>   ..$ : chr "naa.5000a7203007ed8f"
>   ..$ : chr "naa.5000a7203007ed8f"
>   ..$ : chr "naa.5000a7203007ed8f"
>  $ vmfs:List of 4
>   ..$ : num 3
>   ..$ : num 3
>   ..$ : num 5
>   ..$ : num 5
>  $ vmdk:List of 4
>   ..$ : chr "eager"
>   ..$ : chr "lazy"
>   ..$ : chr "eager"
>   ..$ : chr "lazy"
>  $ IOPS:List of 4
>   ..$ : num 16887
>   ..$ : num 44623
>   ..$ : num 16768
>   ..$ : num 45892
>  $ BW  :List of 4
>   ..$ : num 66
>   ..$ : num 174
>   ..$ : num 65.5
>   ..$ : num 179
>
> I would like Y axis to represent BW and X axis to represent
> disk, vmfs and vmdk.
>
> All the examples in books or online have single X axis. I could
> not
> find an example which does something similar to what I am
> trying. Can
> anyone please give me some pointers?
>
> Thanks and Regards,
> Prasad
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible
> code.
>



More information about the R-help mailing list