简体   繁体   中英

how to graph two columns in box plot in R

I know there's a simple solution to this, but I've been getting nowhere, despite a few hours trying. New to R...Thanks for any help.

I created a dataset with two columns with headers "X1959" and "X2013". In these columns is the number of references I found for 100 sequential published papers in the same journal for these two different years (1959, 2013).

I want to graph both of these columns and determine whether they are statistically significant populations. (The y-value is just the range of their values, or the number of references I found for each of the 100 papers). Would love a box plot, but a bar graph would be fine, too.

What I tried: Rotating the columns into rows...but this left no column IDs for the new columns, and I still couldn't figure out how to graph the two years together. Adding a new column "references" with the numbers 1:100.

Thanks!

What have you tried?

If your data frame looks something like this

df <- data.frame(X1959=sample(20), X2013=sample(20))

You can create a boxplot like this

boxplot(df)

If you have other variables in your data frame, you may want to do this instead

boxplot(df[, c("X1959", "X2013")])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM