Working with violin plot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Working with violin plot

Mahmood Naderan-Tahan
Hi

I would like to use the violin plot as described in the manual [1]. In the example, I see

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
head(ToothGrowth)

On the other hand, my data is a csv file containing some rows and numbers. Problem is that the following code doesn't work


> mydata <- read.csv('test.csv', header=T,row.names=1)
> mydata
     V1  V2   V3 V4
P1 73.6 0.7 74.6  R
P2 75.2 0.7 75.8  R
P3  6.5 0.0  7.3  R
P4 41.4 0.3 39.2  C
P5  5.4 0.1 18.2  C
P6 18.8 0.3 30.3  C
> library(ggplot2)
> p <- ggplot(ToothGrowth, aes(x=V4, y=V1)) + geom_violin()
> p
Error in FUN(X[[i]], ...) : object 'V4' not found


Any idea to fix that?





[1] http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization


Regards,
Mahmood

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Working with violin plot

Mahmood Naderan-Tahan
Please ignore the previous email...


Regards,
Mahmood

________________________________
From: R-help <[hidden email]> on behalf of Mahmood Naderan-Tahan <[hidden email]>
Sent: Wednesday, March 31, 2021 11:19:59 AM
To: [hidden email]
Subject: [R] Working with violin plot

Hi

I would like to use the violin plot as described in the manual [1]. In the example, I see

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
head(ToothGrowth)

On the other hand, my data is a csv file containing some rows and numbers. Problem is that the following code doesn't work


> mydata <- read.csv('test.csv', header=T,row.names=1)
> mydata
     V1  V2   V3 V4
P1 73.6 0.7 74.6  R
P2 75.2 0.7 75.8  R
P3  6.5 0.0  7.3  R
P4 41.4 0.3 39.2  C
P5  5.4 0.1 18.2  C
P6 18.8 0.3 30.3  C
> library(ggplot2)
> p <- ggplot(ToothGrowth, aes(x=V4, y=V1)) + geom_violin()
> p
Error in FUN(X[[i]], ...) : object 'V4' not found


Any idea to fix that?





[1] http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization


Regards,
Mahmood

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Working with violin plot

Eric Berger
In reply to this post by Mahmood Naderan-Tahan
Try replacing
ggplot(ToothGrowth, ... )
with
ggplot(mydata,...)

HTH,
Eric


On Wed, Mar 31, 2021 at 12:20 PM Mahmood Naderan-Tahan <
[hidden email]> wrote:

> Hi
>
> I would like to use the violin plot as described in the manual [1]. In the
> example, I see
>
> ToothGrowth$dose <- as.factor(ToothGrowth$dose)
> head(ToothGrowth)
>
> On the other hand, my data is a csv file containing some rows and numbers.
> Problem is that the following code doesn't work
>
>
> > mydata <- read.csv('test.csv', header=T,row.names=1)
> > mydata
>      V1  V2   V3 V4
> P1 73.6 0.7 74.6  R
> P2 75.2 0.7 75.8  R
> P3  6.5 0.0  7.3  R
> P4 41.4 0.3 39.2  C
> P5  5.4 0.1 18.2  C
> P6 18.8 0.3 30.3  C
> > library(ggplot2)
> > p <- ggplot(ToothGrowth, aes(x=V4, y=V1)) + geom_violin()
> > p
> Error in FUN(X[[i]], ...) : object 'V4' not found
>
>
> Any idea to fix that?
>
>
>
>
>
> [1]
> http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization
>
>
> Regards,
> Mahmood
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Working with violin plot

Mahmood Naderan-Tahan
Yes thank you very much.


Regards,
Mahmood

________________________________
From: Eric Berger <[hidden email]>
Sent: Wednesday, March 31, 2021 11:30:48 AM
To: Mahmood Naderan-Tahan
Cc: [hidden email]
Subject: Re: [R] Working with violin plot

Try replacing
ggplot(ToothGrowth, ... )
with
ggplot(mydata,...)

HTH,
Eric


On Wed, Mar 31, 2021 at 12:20 PM Mahmood Naderan-Tahan <[hidden email]<mailto:[hidden email]>> wrote:
Hi

I would like to use the violin plot as described in the manual [1]. In the example, I see

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
head(ToothGrowth)

On the other hand, my data is a csv file containing some rows and numbers. Problem is that the following code doesn't work


> mydata <- read.csv('test.csv', header=T,row.names=1)
> mydata
     V1  V2   V3 V4
P1 73.6 0.7 74.6  R
P2 75.2 0.7 75.8  R
P3  6.5 0.0  7.3  R
P4 41.4 0.3 39.2  C
P5  5.4 0.1 18.2  C
P6 18.8 0.3 30.3  C
> library(ggplot2)
> p <- ggplot(ToothGrowth, aes(x=V4, y=V1)) + geom_violin()
> p
Error in FUN(X[[i]], ...) : object 'V4' not found


Any idea to fix that?





[1] http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization


Regards,
Mahmood

        [[alternative HTML version deleted]]

______________________________________________
[hidden email]<mailto:[hidden email]> mailing list -- To UNSUBSCRIBE and more, see
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.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.