this is my first time asking a question on here. I am tirelessly working on this lab that was due ages ago but was able to get extended. I am not sure what I am doing anymore. I have to be able to do statistical anyalysis and do one of four tests: Correlation, Linear regression, T-test and ANOVA.
Currently what I am faced with is just getting my dataset to be readable in a wide format on R and currently what it looks like is: dataset I have been able to do the bare minimum which is get it read but my lesson tells me that it needs to be in a wide format and from what it looks like, it is not even in that formatting. I know I would have to run an ANOVA test as there is more than 2 categories that are being tested, but I do not know how to change variable name on the program nor do I know how to get it to run a statistical data as it is not reading the way I want it to. Any suggestions would be helpful! Thanks.
edit: here's my code
# Statistical Data for Lab 2: Measuring Diversity
Lab2 <- read.csv2('Lab2Measure.csv')
Lab2_wide <- Lab2
to which it gives me the following output:
> X.x1.y1.z1.x2.y2.z2
> 1 1,4,80,10,4,100,0
> 2 2,5,90,5,6,90,5
> 3 3,3,100,20,5,90,0
> 4 4,6,60,5,6,57,0
> 5 5,8,70,3,6,95,2
> 6 6,5,95,6,5,25,0
> 7 7,5,80,15,3,90,10
> 8 8,3,75,20,4,80,0
> 9 9,5,70,25,3,85,10
> 10 10,7,95,5,6,97,2
> 11 11,6,90,2,5,90,0.5
> 12 12,5,70,1,5,75,5
> 13 13,3,60,15,3,97,1
> 14 14,4,90,10,2,70,0
> 15 15,3,85,8,3,98,1
> 16 16,2,96,17,8,90,5
> 17 17,5,70,20,5,98,1
> 18 18,3,40,10,4,80,9
> 19 19,3,80,15,4,95,0
> 20 20,1,90,2,2,92,0
> 21 21,2,75,7,2,96,5
but please refer to the photo provided to understand my woes
CodePudding user response:
When you see a column name like:
X.x1.y1.z1.x2.y2.z2
It means you didn't give the correct separator to the read function:
The default for read.table
is whitespace. Default for read.csv2
is semicolon. You can change the separator to be used by read.table
with the sep
parameter. I'm not sure that you can change the separator of read.csv2
or read.csv
with that parameter. I think they may throw an error if you try. As user 20650 suggests, you may get success with:
Lab2 <- read.csv("Lab2Measure.csv")
Rather than using images of datasets or the results you should learn to post the copied text from the console .
CodePudding user response:
Lab2 <- read.csv2('Lab2Measure.csv', sep=",")
Lab2_wide <- Lab2