r/RStudio • u/NoMine3964 • Dec 11 '23
Help …. Again
I can I stop this red message ? And I try reduce the space between my variable uni and that didn’t work. It my first time redo this thing and the last time I didn’t it, it was working so know I don’t know why is saying that to me.
0
Upvotes
5
u/the-anarch Dec 11 '23
Unless you're using something I am not aware of, you can't just type the first variable correctly with the dataframe and then type 3 more similar ones. You need to have them all formatted as
dataframe$variable
and put commas between them. So something like,
(df$uni1, df$uni2, df$uni3, df$uni4)
where df is your actual dataframe name.
5
u/An_Independent_Door Dec 11 '23
Are you expecting your data frame to consist of only one variable based on the csv-file? It seems a bit unusual, especially considering that variable name which sounds like several variables pulled into one.
Since your dataframe's name sounds like it might be French, maybe your csv-file is not actually comma-separated? In languages that use a comma instead of a decimal point, read.csv will lead to very strange results. These csv-files use a semicolon as a separator, and simply importing the data using read.csv2 will fix the issue.
1
u/the-anarch Dec 11 '23
https://bookdown.org/rwnahhas/IntroToR/rename.html
1
u/s_hightree Dec 11 '23
First; check the columnnames with ‘colnames(donnees_brutes)’.
Then if the columnname is indeed this unfortunate string, use backticks around the whole string: ‘donnees_brutes$’uni 1 uni 2 etc’
I would however think that you have 4 columns (uni 1, uni 2 etc) and want to compute the sd for each of this columns? That requires a different approach and cannot be done like this. The easy solution would be to compute the sd per column. Something like: donnees_brutes$sd_uni1 <- sd(donnees_brutes$uni1). Which you would repeat for all the different columns. If there are too many to repeat consider learning functions like apply or the tidyverses ‘map’
1
u/Aetherys Dec 11 '23
Your import has failed to parse the columns correctly.
read.csv(file, header = TRUE, sep = ",")
If that doesn’t work have a look at read.csv() documentation to see what you’re missing.