I'm trying to use the logisticPCA package with my own data. The functions of this package only work with binary data which is what i'm looking for but, the first column which usually contains the observation name or group is taken as a regular variable and doesn't work since it's non-binary data.
The package itself contains a data named house_votes84 which, although having the first column as the group name of each observation (democrat/republican) it's not recognized as a variable and the functions of the package work perfectly. Actually, in this website: some graphs are created by first extracting the row names of the first column:
party = rownames(house_votes84)
I have tried many different ways to import a data.frame (mainly .csv from the notepad, with the first row, the headers, with one less name) with the first column containing the names but not being considered as a variable without success.
How do I creater or emulate this data structure in R?
handicapped-infants water-project-cost-sharing
republican 0 1
republican 0 1
democrat NA 1
democrat 0 1
democrat 1 1
Data.frame from house_votes84 simplified (row.names and 2 variables instead of 16)
read.csv
or similar? If so, give a glance in?read.table
to therow.names
argument. Otherwise, say that the column containing the row names is the first anddf
is your data.frame. You can set the row names withrownames(df)<-df[[1]]
and then eliminate the column withdf[[1]]<-NULL
. – nicolaread.table
tells me that either i'm duplicating row.names when 1 is given or simply names the first column "row.names" when NULL is given. The other way you proposed also prompts me a message saying i'm duplicating row.names. Thanks anyway! – N.S.I