How would I organize the data from https://users.stat.ufl.edu/~winner/data/sexlierel.dat to make an accurate analysis? I am having trouble plotting the different types of data with the way it is given to me.
description: https://users.stat.ufl.edu/~winner/data/sexlierel.txt
```{r}
data_set <- read.csv("project_data.csv", header = TRUE)
names(data_set)
summary(data_set)
summary(data_set$Gender)
```
CodePudding user response:
I don't think that data is a "true" CSV file. There are no commas or other delimiters.
you may need to look at read.tsv which is tab separated data?
CodePudding user response:
As @CALUM Polwart said, this is not a comma separated file. It is a fixed width file. You can also consider spaces as the delimiter. There are many packages with functions that can help. For example, you could use
library(data.table)
data_set <- fread("so/sexlierel.txt")
or
library(tidyverse)
data_set <- readr::read_table("so/sexlierel.txt")
You may want to set the column names when you read it. You could use
library(tidyverse)
data_set <- readr::read_table("so/sexlierel.txt", col_names = c("gender", "scale", "psm", "ptl", "religiosity", "count"))
or
library(tidyverse)
data_set <- readr::read_table("so/sexlierel.txt")
names(data_set) <- c("gender", "scale", "psm", "ptl", "religiosity", "count")