-1

I have some problems when using R

head(data)
  pclass.survived.sex.age
1           1,1,female,29
2           1,1,male,0.92
3            1,0,female,2
4             1,0,male,30
5           1,0,female,25
6             1,1,male,48

table(data$survived,data$sex)
# < table of extent 0 x 0 >

what does this mean table of extent 0x0 and how can I solve this?
Column sex is female and male.
Column survived is 1 and 0

Cath
  • 23,906
  • 5
  • 52
  • 86
Hoa Nguyen
  • 11
  • 1
  • 1

1 Answers1

1

Most probably you have imported your file incorrectly. Usually, you would read your .csv file in a manner similar to the code below:

df <- read.csv("myRandomFile.csv", header=TRUE)

When reading data from Excel you could make use of a designated package, like in the example below:

library(XLConnect) # load XLConnect package 
wk = loadWorkbook("mydata.xls") 
df = readWorksheet(wk, sheet="Sheet1") 

After, it would be good to check the import with use of dim, rownames and colnames. If you are experiencing problems with reading your file correctly you may consider reading it line by line for a few initial lines and posting a reproducible example here so other users can suggest solutions.

Konrad
  • 17,740
  • 16
  • 106
  • 167