Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R STUDIO AND STATISTICS. NEED HELP WITH MY HOMEWORK I HAVE TO UPLOAD IT BY TOMORROW :( PLEASEEE #191

Open
MellowR2 opened this issue Aug 9, 2024 · 0 comments

Comments

@MellowR2
Copy link

MellowR2 commented Aug 9, 2024

I've been working on this code the last few days but I know nothing about RStudio, so I tried looking for information on google and even tried with AI but still the code doesn't run, it keeps bringing all these error messages, please help:

Code:

Cargar las librerías necesarias

library(readxl)
library(moments)

Cargar los datos desde el archivo Excel (.xlsx) usando la ruta proporcionada

Car <- read_excel("Car.xlsx", sheet = "in")

Limpiar los nombres de las columnas (eliminando comillas y espacios adicionales)

colnames(Car) <- gsub('[\",]', '', colnames(Car))

Verificar los nombres de las columnas después de la limpieza

colnames(Car)

Convertir columnas relevantes a numéricas y factores

Car$speed1 <- as.numeric(Car$speed1)
Car$type4 <- as.factor(Car$type4)
Car$pollution3 <- as.numeric(Car$pollution3)
Car$pollution5 <- as.numeric(Car$pollution5)

Ejercicio 1: Cálculo de la Velocidad Promedio

vel1 <- mean(Car$speed1, na.rm = TRUE)
vel1
cat("La velocidad promedio de speed1 es", vel1, "\n")

Ejercicio 2: Determinación del Tipo más Frecuente en Type4

Mod1 <- names(which.max(table(Car$type4)))
Mod1
cat("El tipo más frecuente en type4 es", Mod1, "\n")

Ejercicio 3: Cálculo de la Curtosis para Speed1

curtosis1 <- kurtosis(Car$speed1, na.rm = TRUE)
curtosis1
cat("La curtosis de speed1 es", curtosis1, "\n")

Ejercicio 4: Cálculo de la Desviación Estándar para Pollution3 y Pollution5

DESV1 <- sd(Car$pollution3, na.rm = TRUE)
DESV2 <- sd(Car$pollution5, na.rm = TRUE)
cat("La desviación estándar de pollution3 es", DESV1, "\n")
cat("La desviación estándar de pollution5 es", DESV2, "\n")

Ejercicio 5: Cálculo de la Varianza para Speed1

varianza1 <- var(Car$speed1, na.rm = TRUE)
varianza1
cat("La varianza de speed1 es", varianza1, "\n")

Gráficos

Gráfico de densidad para Speed1

plot(density(Car$speed1, na.rm = TRUE), main = "Densidad de Speed1", xlab = "Speed1")

Gráfico de barras para la frecuencia de tipos en Type4

barplot(table(Car$type4), main = "Frecuencia de Type4", xlab = "Type4", ylab = "Frecuencia")

Gráficos de densidad para Pollution3 y Pollution5

plot(density(Car$pollution3, na.rm = TRUE), main = "Densidad de Pollution3", xlab = "Pollution3")
plot(density(Car$pollution5, na.rm = TRUE), main = "Densidad de Pollution5", xlab = "Pollution5")

Boxplot para mostrar la dispersión de los datos en Speed1

boxplot(Car$speed1, main = "Dispersión de Speed1", ylab = "Speed1")

Guardar los gráficos en un archivo PDF

pdf("graficas_tarea.pdf")
plot(density(Car$speed1, na.rm = TRUE), main = "Densidad de Speed1", xlab = "Speed1")
barplot(table(Car$type4), main = "Frecuencia de Type4", xlab = "Type4", ylab = "Frecuencia")
plot(density(Car$pollution3, na.rm = TRUE), main = "Densidad de Pollution3", xlab = "Pollution3")
plot(density(Car$pollution5, na.rm = TRUE), main = "Densidad de Pollution5", xlab = "Pollution5")
boxplot(Car$speed1, main = "Dispersión de Speed1", ylab = "Speed1")
dev.off()
Car.xlsx

Instructions:
Based on the examples seen in class, answer the following statements. The submission must be made in a Word document that contains the answers to each of the statements and attach a script with the instructions used to reach the solution to the task.

Each exercise presents a problem appropriate to a distribution, for each one you must make a density graph, as well as answer the questions that are asked using the R functions of cumulative distribution, quartile or density.

Groups of 4 people maximum
Don't forget to indicate name
One delivery per group

  1. What is the average speed in the Speed1 Category?
  2. What is the most common type in the Type4 category?
  3. Kurtosis (kurtosi(x)) tells me the degree of skewness of a data set (true or false)
  4. The standard deviation in Pollution type 3 and 5 (pollution3 and pollution5) is?
  5. Determine how dispersed the data is from the mean (Insert name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant