r - Reading from .csv file giving me a vector, not a dataframe? -


i new r , struggling import data .csv file.

specifically, trying pull 31 responses, "1", "2", "3", , "4" .csv file. data under header q21

so tried doing:

c <- mydata["q21"] #because (mydata$21) gave "$ operator invalid atomic vectors response  

but returned [1] na

i looking 31 integer responses.

no idea i'm doing wrong. appreciate , on feet language.

edit:

str(mydata) yields chr "/users/charles/documents/work/survey/csv/acme_company.csv"

i did use read.csv(mydata) , produced everything, seemed have column headings q20.

when typed in c <- mydata$q21 (that typo wrote before), got: error in mydata$q21 : $ operator invalid atomic vectors

mydata[1:3,] error in mydata[1:3, ] : incorrect number of dimensions

is.data.frame(mydata) [1] false

colnames(mydata) null

mydata[, "q21"] error in mydata[, "q21"] : incorrect number of dimensions

so don't know-- mydata isn't data frame, right? should if want use information in it?

sounds mydata not dataframe vector; read.csv() didn't return dataframe. (post command used read data, post output of str(mydata) ).

(mydata$21) gave "$ operator invalid atomic vectors response


that's error, meant mydata$q21. mydata$21 attempting access column named 21 not q21. read error messages more closely ;-)

mydata["q21"] returned [1] na

first, check if mydata has column called q21 or not. show colnames(mydata).

second, slice of column, need mydata[, "q21"] , absolutely need leading comma, signifies thing after comma column names or indices.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -