棒グラフと散布図

library(readxl)
asia <- read_excel("asia.xlsx")
barplot(asia$ctfp,names.arg = asia$countrycode)

barplot(asia$pop,names.arg=asia$countrycode)

plot(asia$pop,asia$rgdpe)

plot(asia$pop,asia$rgdpe,log="xy")

plot(asia$pop,asia$rgdpe,log="xy",pch=4)

plot(asia$pop,asia$rgdpe,log = "xy",xlab="Population",ylab="GDP")

library(readxl)
pwt1950sgp <- read_excel("pwt1950sgp.xlsx")
df<-pwt1950sgp
## You can use the below code to generate the graph.
## Don't forget to replace the 'df' with the name
## of your dataframe

# You need the following package(s):
library("ggplot2")

# The code below will generate the graph:
graph <- ggplot(df, aes(x = year, y = percapitaGDP, colour = countrycode)) +
  geom_point()+
  geom_smooth(se = FALSE, method = 'lm') +
  theme_bw()
graph
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).

# If you want the plot to be interactive,
# you need the following package(s):
library("plotly")
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
ggplotly(graph)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
# If you would like to save your graph, you can use:
ggsave('my_graph.pdf', graph, width = 14, height = 14, units = 'cm')
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Removed 2 rows containing missing values (geom_point).

データ

library(readxl)
df <- read_excel("asia.xlsx")

ローカルでlibrary(ggplotgui)

## You can use the below code to generate the graph.
## Don't forget to replace the 'df' with the name
## of your dataframe

# You need the following package(s):
library("ggplot2")

# The code below will generate the graph:
graph <- ggplot(df, aes(x = ctfp, y = percapitaGDP)) +
  geom_point()+
  geom_smooth(se = TRUE, method = 'lm') +
  theme_bw()
graph
## `geom_smooth()` using formula 'y ~ x'

# If you want the plot to be interactive,
# you need the following package(s):
library("plotly")
ggplotly(graph)
## `geom_smooth()` using formula 'y ~ x'
# If you would like to save your graph, you can use:
ggsave('my_graph.pdf', graph, width = 14, height = 14, units = 'cm')
## `geom_smooth()` using formula 'y ~ x'