Hi Bert,
After doing sapply(your_dataframe, "class"), it seems like R is recognizing
that the field is of type numeric after all, the problem (it seems) is how
the import_list() function from the rio package is reading the data (my
suspicion).
Best regards,
Paul
El mar, 30 ene 2024 a las 14:59,
Hi Bert,
Below the information you asked me for:
nrow(mydataset)
[1] 2986276
sapply(mydataset, "class")
$`Transit Date`
[1] "POSIXct" "POSIXt"
$`Market Segment`
[1] "character"
$`NĂºmero de TrĂ¡nsitos`
[1] "numeric"
$`Tar No`
[1] "character"
$`Beam Range (Operations)`
[1] "character"
And your other option - recode what gets imported. It may well be you will
actually want the blanks to be NAs for instance rather than blank. I'm
assuming the True and False are >$0 and $0 from your description. (Or maybe
vice versa). So I'd have made my column name something like
"OverZeroDollars"
If you are using the read_excel() function from the readxl package, then
there's an argument named col_types that lets you specify the types to use.
You could specify col_types = "numeric" to read all columns as numeric
columns. If some columns are different types, you should specify a
vector
Incidentally, "didn't work" is not very useful information. Please tell us
exactly what error message or apparently aberrant result you received.
Also, what do you get from:
sapply(your_dataframe, "class")
nrow(your_dataframe)
(as I suspect what you think it is, isn't).
Cheers,
Bert
On Tue, Jan
Dear friend Duncan,
Thank you so much for your kind reply. Yes, that is exactly what is
happening, there are a lot of NA values at the start, so R assumes that the
field is of type boolean. The challenge that I am facing is that I want to
read into R an Excel file that has many sheets (46 in this
On 30/01/2024 11:10 a.m., Paul Bernal wrote:
Dear friends,
Hope you are doing well. I am currently using R version 4.3.2, and I have a
.xlsx file that has 46 sheets on it. I basically combined all 46 sheets
and read them as a single dataframe in R using package rio.
I read a solution using pac
Dear friends,
Hope you are doing well. I am currently using R version 4.3.2, and I have a
.xlsx file that has 46 sheets on it. I basically combined all 46 sheets
and read them as a single dataframe in R using package rio.
I read a solution using package readlx, as suggested in a StackOverflow
di
8 matches
Mail list logo