# Define the data
planets <- c("MERCURY", "VENUS", "EARTH", "MOON", "MARS", "JUPITER", "SATURN", "URANUS", "NEPTUNE", "PLUTO")
mass <- c(0.33, 4.87, 5.97, 0.073, 0.642, 1898, 568, 86.8, 102, 0.013)
diameter <- c(4879, 12104, 12756, 3475, 6792, 142984, 120536, 51118, 49528, 2376)
density <- c(5429, 5243, 5514, 3340, 3934, 1326, 687, 1270, 1638, 1850)
gravity <- c(3.7, 8.9, 9.8, 1.6, 3.7, 23.1, 9, 8.7, 11, 0.7)
escape_velocity <- c(4.3, 10.4, 11.2, 2.4, 5, 59.5, 35.5, 21.3, 23.5, 1.3)
rotation_period <- c(1407.6, -5832.5, 23.9, 655.7, 24.6, 9.9, 10.7, -17.2, 16.1, -153.3)
length_of_day <- c(4222.6, 2802, 24, 708.7, 24.7, 9.9, 10.7, 17.2, 16.1, 153.3)
distance_from_sun <- c(57.9, 108.2, 149.6, 0.384, 228, 778.5, 1432, 2867, 4515, 5906.4)
perihelion <- c(46, 107.5, 147.1, 0.363, 206.7, 740.6, 1357.6, 2732.7, 4471.1, 4436.8)
aphelion <- c(69.8, 108.9, 152.1, 0.406, 249.3, 816.4, 1506.5, 3001.4, 4558.9, 7375.9)
orbital_period <- c(88, 224.7, 365.2, 27.3, 687, 4331, 10747, 30589, 59800, 90560)
orbital_velocity <- c(47.4, 35, 29.8, 1.0, 24.1, 13.1, 9.7, 6.8, 5.4, 4.7)
orbital_inclination <- c(7, 3.4, 0, 5.1, 1.8, 1.3, 2.5, 0.8, 1.8, 17.2)
orbital_eccentricity <- c(0.206, 0.007, 0.017, 0.055, 0.094, 0.049, 0.052, 0.047, 0.01, 0.244)
obliquity_to_orbit <- c(0.034, 177.4, 23.4, 6.7, 25.2, 3.1, 26.7, 97.8, 28.3, 119.5)
mean_temperature <- c(167, 464, 15, -20, -65, -110, -140, -195, -200, -225)
surface_pressure <- c(0, 92, 1, 0, 0.01, NA, NA, NA, NA, 0.00001)
number_of_moons <- c(0, 0, 1, 0, 2, 79, 83, 28, 14, 5)
ring_system <- c("No", "No", "No", "No", "No", "Yes", "Yes", "Yes", "Yes", "No")
global_magnetic_field <- c("Yes", "No", "Yes", "No", "No", "Yes", "Yes", "Yes", "Yes", "Unknown")
# Create a data frame
planets_data <- data.frame(Planet = planets, Mass = mass, Diameter = diameter, Density = density, Gravity = gravity, Escape_Velocity = escape_velocity,
Rotation_Period = rotation_period, Length_of_Day = length_of_day, Distance_from_Sun = distance_from_sun,
Perihelion = perihelion, Aphelion = aphelion, Orbital_Period = orbital_period, Orbital_Velocity = orbital_velocity,
Orbital_Inclination = orbital_inclination, Orbital_Eccentricity = orbital_eccentricity,
Obliquity_to_Orbit = obliquity_to_orbit, Mean_Temperature = mean_temperature, Surface_Pressure = surface_pressure,
Number_of_Moons = number_of_moons, Ring_System = ring_system, Global_Magnetic_Field = global_magnetic_field)
# Plotting
par(mfrow=c(2, 2))
barplot(planets_data$Mass, names.arg = planets_data$Planet, main = "Mass (10^24kg)", ylab = "Mass (10^24kg)", las=2, col="#0066FF")
barplot(planets_data$Diameter, names.arg = planets_data$Planet, main = "Diameter (km)", ylab = "Diameter (km)", las=2, col="#00FF66")
barplot(planets_data$Density, names.arg = planets_data$Planet, main = "Density (kg/m3)", ylab = "Density (kg/m3)", las=2, col="#FF0066")
barplot(planets_data$Gravity, names.arg = planets_data$Planet, main = "Gravity (m/s2)", ylab = "Gravity (m/s2)", las=2, col="#FF6600")

par(mfrow=c(2, 2))
barplot(planets_data$Escape_Velocity, names.arg = planets_data$Planet, main = "Escape Velocity (km/s)", ylab = "Escape Velocity (km/s)", las=2, col="#00CCFF")
barplot(planets_data$Rotation_Period, names.arg = planets_data$Planet, main = "Rotation Period (hours)", ylab = "Rotation Period (hours)", las=2, col="#00FFCC")
barplot(planets_data$Length_of_Day, names.arg = planets_data$Planet, main = "Length of Day (hours)", ylab = "Length of Day (hours)", las=2, col="#FF00CC")
barplot(planets_data$Distance_from_Sun, names.arg = planets_data$Planet, main = "Distance from Sun (10^6 km)", ylab = "Distance from Sun (10^6 km)", las=2, col="#FFCC00")
