Displaying 3 results from an estimated 3 matches for "setnum".
Did you mean:
seqnum
2017 Aug 30
2
Converting character to numeric using the package "XLConnect"
...file, some numbers in the cells are stored as text (instead of numeric). Here is my code (the Excel file is attached):
rm(list=ls(all=TRUE))
library(XLConnect)
tab <- loadWorkbook("C:/Users/Downloads/File.xlsx", create = TRUE)
set <- readWorksheet(tab, sheet = "settings")
setNum <- readWorksheet(tab, sheet = "settings", colTypes="numeric")
index <- which((!is.na(setNum)), arr.ind=TRUE)
if(length(index)!=0){
set[index] <- unlist(lapply(set[index], function(x) as.numeric(as.character(x))))
}
## to check
set[10,1] ## Problem: must be numeric !!!...
2017 Aug 30
0
Converting character to numeric using the package "XLConnect"
...r xls files). You could send a "csv" file with extension of ".txt".
>
> rm(list=ls(all=TRUE))
> library(XLConnect)
> tab <- loadWorkbook("C:/Users/Downloads/File.xlsx", create = TRUE)
> set <- readWorksheet(tab, sheet = "settings")
> setNum <- readWorksheet(tab, sheet = "settings", colTypes="numeric")
Presumably you could also send the results of
dput(setNum)
.. either as a .txt attachment or embedded in an email.
> index <- which((!is.na(setNum)), arr.ind=TRUE)
> if(length(index)!=0){
> set[in...
2017 Aug 30
3
Converting character to numeric using the package "XLConnect"
...or xls files). You could send a "csv" file with extension of ".txt".
>
> rm(list=ls(all=TRUE))
> library(XLConnect)
> tab <- loadWorkbook("C:/Users/Downloads/File.xlsx", create = TRUE)
> set <- readWorksheet(tab, sheet = "settings")
> setNum <- readWorksheet(tab, sheet = "settings", colTypes="numeric")
Presumably you could also send the results of
dput(setNum)
.. either as a .txt attachment or embedded in an email.
> index <- which((!is.na(setNum)), arr.ind=TRUE)
> if(length(index)!=0){
> set[ind...