I'm a newbie in R. I have a 24MB CSV file. Reads this into RStudio on my MacBook Air with OS Yoswmite, 4GB RAM. R version 3.1.1 (2014-07-10). Viewing the contents of View (df) is OK. Attempting to apply filter. Do not get any hits. Attempting to cast from character to number. R replacing all charaters with NA in the column where the casting is done! What happens here? It seems that R can not read the contents of the cells. Is there anything about encoding? This is what I have done so fare: First a summary:
R Code:
eiendommer <- read.csv("eiendommer.csv",  sep = ";", quote = "",  encoding="UTF-8", stringsAsFactors = FALSE)
View(eiendommer)# I can view the content of the csv file
filtereiendommer <- filter(eiendommer, kommune == "0101")# no match
filtereiendom <- eiendommer [eiendommer$kommune == "0101",]#no match
utvalg <- eiendommer[160567:161934,]#manual selection of rows do work             utvalgsortert <- arrange(utvalg, desc(jordbruksareal), desc(skogareal))# works
View(utvalgsortert)
##Try to transform columns from character to number. 
transformedEiendom <- transform(sortertEiendom, jordbruksareal = as.numeric(jordbruksareal),
                       skogareal = as.numeric(skogareal) )
#This result in NA where it earlier was characters with lengt 1-3:"646", "18", "2" 
Summary:
kommune           X.gardsnr.         X.bruksnr.         X.festenr.         bruksnavn         jordbruksareal    
 Length:207554      Length:207554      Length:207554      Length:207554           Length:207554      Length:207554     
 Class :character   Class :character   Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character   Mode  :character   Mode  :character  
 X.annetareal.       skogareal         X.fulldyrket.        X.overflatedyrket. X.innmarksbeite.  
 Length:207554      Length:207554      Length:207554      Length:207554      Length:207554     
 Class :character   Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character   Mode  :character  
Head:
head(eiendommer)
  kommune X.gardsnr. X.bruksnr. X.festenr.    bruksnavn jordbruksareal X.annetareal. skogareal X.fulldyrket.
1  "0101"        "1"        "1"        "0" "PRESTEGÅRD"            "0"           "5"       "0"           "0"
2  "0101"        "1"        "6"        "0"         "MO"            "8"           "4"       "7"           "8"
3  "0101"        "1"        "9"        "0"  "BERG GÅRD"          "415"          "16"      "39"         "415"
4  "0101"        "2"        "1"        "0"     "BOBERG"          "467"          "22"     "276"         "463"
5  "0101"        "4"        "1"        "0"  "LUNDESTAD"          "877"          "62"     "793"         "837"
6  "0101"        "4"        "5"        "0"     "LEIREN"           "74"          "14"     "165"          "74"    
 
     
    