When I use summary() function in R, it gives me correct output for continuous numerical variables, but it does not give me the frequency tables for character variables. My colleague uses the same code on the same data sets and gets the frequency tables. I have the most updated version of R. What can I do to get summary to work for me? (Note: it never works, no matter what data set I use, even data sets from tutorials on R.)
This is the output I get:
summary(chem)
#> plantid species deerpr forest
#> Length:104 Length:104 Length:104 Length:104
#> Class :character Class :character Class :character Class :character
#> Mode :character Mode :character Mode :character Mode :character
This is the output she gets:
summary(chem)
#> plantid species deerpr forest
#> B1 : 1 fagr:102 higher:45 baldpate :34
#> B10 : 1 lower :57 curlis :10
#> B100 : 1 eames :13
#> B12 : 1 herrontown:23
#> B13 : 1 rosedale :22
#> B15 : 1
#> (Other):96
if you do this:
You will get the same result of your colleague.
As someone suggested in the comments (for some reason I don't see that comment anymore), it's likely that you have two different R versions, or anyway when you read your data you do it in two different ways.
Therefore, for your colleague all strings gets read as factors, while you keep them like strings.
Just convert all character variables to factor.
You can also do it this way, in case you have other columns that you don't want to transform to factor: