I am trying to expand the amount of factors shown in one custom Posixct field where the normal way (str(DF, list.len=ncol(DF), vec.len=20)
) does not work.
I request here 20 but it shows all the time two ("2017-01-01 08:40:00" "2017-01-01 08:50:00" ...
) regardless the length of the list
(here 3
).
Data data.csv
"AAA", "BBB"
1, 01012017-0940+0100
2, 01012017-0950+0100
3, 01012017-0838+0100
Code
library('methods') # setClass
# https://unix.stackexchange.com/a/363290/16920
setClass('iso8601')
# https://mcmap.net/q/143826/-only-read-selected-columns
setAs("character","iso8601",function(from) strptime(from,format="%d%m%Y-%H%M%z"))
DF <- read.csv(file='data.csv',
sep=',',
header=TRUE,
colClasses=c('numeric','iso8601'),
strip.white=TRUE)
DF
str(DF, list.len=ncol(DF), vec.len=20)
Output in R 3.3.3
AAA BBB
1 1 2017-01-01 08:40:00
2 2 2017-01-01 08:50:00
3 3 2017-01-01 07:38:00
'data.frame': 3 obs. of 2 variables:
$ AAA : num 1 2 3
$ BBB : POSIXlt, format: "2017-01-01 08:40:00" "2017-01-01 08:50:00" ...
Output in R 3.4.0
Same as above, reproducing the same problem.
AAA BBB
1 1 2017-01-01 08:40:00
2 2 2017-01-01 08:50:00
3 3 2017-01-01 07:38:00
'data.frame': 3 obs. of 2 variables:
$ AAA: num 1 2 3
$ BBB: POSIXlt, format: "2017-01-01 08:40:00" "2017-01-01 08:50:00" ...
How can you expand
str(DF, list.len=ncol(DF), vec.len=20)
to many factors per variable?How can you show the amount of items per variable in
str(DF)
? Etc without the expansion of the parameters itself in the variable.
Eliminate terminal width and column factor in etiology
I did
- increased the defaults: width from 80 to 150, and columns from 24 to 38
- restarted the terminal prompt
- run
Rscript myScript.r
- Output same again so the terminal width and column amount do not seem to play a factor here
Roland's proposal
The code does not work in all occasions, but in limited number of cases, so it should be possible apply it dynamically
# Roland's comment
str(DF, list.len=ncol(DF), vec.len=20, width = 100)
R: 3.3.3, 3.4.0 (2017-04-21, backports)
OS: Debian 8.7
Window manager: Gnome 3.14.1
as.POSIXct
instead ofstrptime
. There is rarely a reason to store time stamps as POSIXlt. – Catererstrptime(...)
withas.POSIXct(from,format=...")
. Studynigstp(...)
shows that same data type there. What are benefits ofas.POSIXct(...)
here? – Denmanstr(DF, list.len=ncol(DF), vec.len=20, width = 100)
. – Catererstr()
it does not wrap. I simply truncates the returned data. If you drag the width of the console window wider, you get more dates.I spanned two 20" cinemas with it and got all the values on screen for the 10 I requested. You need to adjust the console window to be wider to see it all. – Wafdstr()
falls into exploratory because it is there to check the structure of a data file. So, I do not have the expertise to suggest how to accomplish this task as a command function if expanding the window is not sufficient. – Wafdwidth =
parameter instr
to a large enough number works for me. @Caterer already suggested, this, but I did not see a response comment from you. Can you confirm that this does not work for you? – Miyokomizar