comparison (4) is possible only for Atomic and list types

Asked

Viewed 434 times

0

Good morning,

I have a dataframe whose structure is given by

> head(citationsAllYears)
  appln_id_cited appln_id_citn ano_prior
3            636      56755306      2008
4            636           644      2008
5            644      56755306      2008
6           1096     275471855      2007
7           1607      57977423      2004
8           1607      57977422      2004
>

I need to make a filter per year, so that for each year, I consider a subset of lines for which ano_prior <=year, where "year" is an index. Usually when I do

links <- citationsAllYears[  citationsAllYears$ano_prior <= ano  ,    ]

I usually have the subset I need. I’ve used the same scheme before and it always worked. But since yesterday, when I installed some packages that the igraph requires, this approach does not work and I get the message:

> Error in citationsAllYears$ano_prior <= ano : 
  comparison (4) is possible only for atomic and list types 

I’m with the latest version of R and R-Studio. Where’s the problem?

I’m sorry if the question is too elementary, I’ve only been using R for two months and I’m learning "in real time".

I cannot apply any *apply family command because although it is more efficient, this is a minimal part of what I need to do with millions of data and multiple databases simultaneously. And my laptop at this time does not allow me to process all the data with these commands. Therefore, I need to partition the analysis one year at a time.

Here the Session.info()

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 
[2] LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

attached base packages:
[1] compiler  stats     graphics  grDevices
[5] utils     datasets  methods   base     

other attached packages:
 [1] UsingR_2.0-5    Hmisc_3.17-4   
 [3] ggplot2_2.1.0   Formula_1.2-1  
 [5] survival_2.39-2 lattice_0.20-33
 [7] HistData_0.7-8  MASS_7.3-45    
 [9] dplyr_0.4.3     foreign_0.8-66 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5         cluster_2.0.4      
 [3] magrittr_1.5        splines_3.3.0      
 [5] munsell_0.4.3       colorspace_1.2-6   
 [7] R6_2.1.2            plyr_1.8.3         
 [9] tools_3.3.0         nnet_7.3-12        
[11] parallel_3.3.0      grid_3.3.0         
[13] data.table_1.9.6    gtable_0.2.0       
[15] latticeExtra_0.6-28 DBI_0.4-1          
[17] assertthat_0.1      Matrix_1.2-6       
[19] gridExtra_2.2.1     RColorBrewer_1.1-2 
[21] acepack_1.3-3.3     rpart_4.1-10       
[23] scales_0.4.0        chron_2.3-47       
> 
  • Your command seems correct. Edit your question with the result of sessionInfo() to make it easier to understand what is happening.

  • Done @daniel-Falbel! I don’t know what’s changed in the software! That’s it but I’m stuck! I must reinstall everything?

  • To quickly fix your problem you can explicitly call the function [ using: links <- subset(citationsAllYears, citationsAllYears$ano_prior <= ano). But I still can’t tell what could be causing the first problem.

  • Unfortunately, it was the same problem. I think I’ll reinstall everything because before installing igraph packages I had no problem with these commands. thanks @daniel-Falbel.

  • I believe reinstalling everything will not solve the problem. There is some comparison error in your code. What gives str(ano) and str(citationsAllYears)?

  • Both of the numeric type. @daniel-Falbel. I reloaded everything again and the error just disappeared! I’ve never seen anything like this in two months. Thanks for your help! Abs.

  • Ok! Glad it worked out! I will vote to close your question because it is not a reproducible mistake.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.