I was trying o import file using read.table function but there was some error and it was getting imported. Kindly inform me was there any error in the syntax.
I am attaching the R screen
@sanchi_singh1 : R is unable to read single backslash (i.e. \ ) . Instead of “” u have to use “/” or "\ ".
Below is the example :
data1 = read.table(file = “D:/PP/ test/xyz.csv”, header = T, sep = “,”)
@sanchi_singh1 - Why dont u try
data1 = read.csv(“D:/PP/Importing File in R/LungCapdatacsv.csv”, header = T, sep =",", stringsAsFactors=F) # This is the easiest method to import Csv in R
and if your data size is big use
data1 = fread(“D:/PP/Importing File in R/LungCapdatacsv.csv”, header = T, sep =",", stringsAsFactors=F)
Thanks a ton Hunaid. I tried the above given function read.csv and file was imported successfully. Please tell me why we use stringsAsFactors=F.
By default read csv converts Character variables to Factors. So it does not allow character to be converted to Factors. Hope this helps!!!
So that means if there is a variable say Gender which contains character of strings Female and Male so R will store them as 0 and 1 is it??
I was trying to use levels function but it is returning null. Please help me out with this. Thanks in advance…
Thank you Hunaid. Understood Thanks a Ton…