Error in make.names ?

3,362 views
Skip to first unread message

João Carlos

unread,
Dec 2, 2013, 8:26:42 PM12/2/13
to shiny-...@googlegroups.com
My very basic app is running fine with RStudio/Shiny (localhost), but after uploading the project to Amazon EC2 running Ubuntu 12 I got the error below:


Loading required package: rgdal Loading required package: sp rgdal: version: 0.8-11, (SVN revision 479M) Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.7.3, released 2010/11/10 Path to GDAL shared files: /usr/share/gdal/1.7 GDAL does not use iconv for recoding strings. Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470] Path to PROJ.4 shared files: (autodetected) Loading required package: scales Loading required package: ggplot2 Loading required package: plyr Loading required package: classInt Loading required package: RColorBrewer Error in make.names(col.names, unique = TRUE) : invalid multibyte string 2 Calls: runApp ... montaBasico -> read.csv -> read.table -> make.names Execution halted


Following the Calls shown with error message I reach to a function which reads 3 csv files and a merge operation:

montaBasico <- function()
{
  basico = read.csv(".././dados/agregados/rj/Basico_RJ_RiodeJaneiro.csv", ";", header=TRUE, dec=",")
  H_Idades = read.csv(".././dados/agregados/rj/hIdades_RiodeJaneiro.csv", ";", header=TRUE, dec=",")
  M_Idades = read.csv(".././dados/agregados/rj/mIdades_RiodeJaneiro.csv", ";", header=TRUE, dec=",")
  
  H_Idades = H_Idades[,c(1,3,106:107)]
  colnames(H_Idades) = c("Cod_setor", "HResidentes", "HIdadeMedia", "HIdadeVar")
  
  M_Idades = M_Idades[,c(1,3,106:107)]
  colnames(M_Idades) = c("Cod_setor", "MResidentes", "MIdadeMedia", "MIdadeVar")
  
  m <- merge(basico,H_Idades, by= "Cod_setor")
  m <- merge(m,M_Idades, by= "Cod_setor")
  colnames(m)[21] = "Domicilios"
  colnames(m)[23] = "RendaMedia"
  colnames(m)[24] = "RendaVar"
  
  m <- merge(m, mapaSetores@data, by.x="Cod_setor" , by.y="CD_GEOCODI" )
  
  return(m)
  
}

Any ideas?

Thanks in advance

Joao Carlos 

Jin Rou New

unread,
Dec 2, 2013, 8:41:00 PM12/2/13
to shiny-...@googlegroups.com
Do you have any accented characters in your files? Could be that they caused the error.

João Carlos

unread,
Dec 2, 2013, 9:03:01 PM12/2/13
to shiny-...@googlegroups.com
yes I do, it's full of Brazilian Portuguese special characters like  ç ã and so on 

With R-Studio in Windows I didnt get any error message, but for displaying then correctly I was using 

encode <- function(x){
  Encoding(x) <- "UTF-8"
  x
}



Joao

jcanistrum

unread,
Dec 2, 2013, 9:16:55 PM12/2/13
to shiny-...@googlegroups.com
Notepad plus apparently detect the files as ANSI encoded

Imagem inline 1.


2013/12/3 João Carlos <jcani...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/P5fXDZvIObg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

encode.jpg

João Carlos

unread,
Dec 3, 2013, 3:36:24 AM12/3/13
to shiny-...@googlegroups.com
read.table did the job  :) 

Joao

Joe Cheng

unread,
Dec 3, 2013, 1:54:48 PM12/3/13
to João Carlos, shiny-...@googlegroups.com
For both read.csv and read.table, it's a good idea to explicitly pass the encoding (try "Windows-1252", for example). The default encodings are different on Windows than other platforms, which is why the code would work fine on your Windows machine but not on the server.


On Tue, Dec 3, 2013 at 12:36 AM, João Carlos <jcani...@gmail.com> wrote:
read.table did the job  :) 

Joao

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages