Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 201839 articles
Browse latest View live
↧

Table % categorical variable from different subsets

I have a dataset with 15 metrics (columns) from a csv. 1 metric is called CancerThis is what the column in the dataset looks likeCancer: yes no yes no I would like to create a table with the...

View Article


Trouble extracting a string from a character vector

I'm having trouble extracting certain matches from my character vector that I named classes using the stringr library:classes =...

View Article


R: collapse rows using two ID variables (one ID nested in the other) [duplicate]

I have a data frame like this:user_id year A 2011 A 2012 A 2012 A 2012 A 2013 A 2013 B 2011 B 2012 B 2012 B 2013 B 2013 B 2013 . . . I would like to collapse this data frame by using user_id and year,...

View Article

creating a matrix with a nested for loop

This is a practice question to prep for an exam. I'm given the following code: W=matrix(1:16,byrow=T,ncol=4) print(W) fmat=function(W){ n=nrow(W) for (i in 1:n){ for (j in 1:n){ W[j,i]=W[i,j]+W[j,i] }...

View Article

How to Calculate Distance between points from a reference point using R?

I have this data frame individual_dets which has some lat and long values in it. This is the dataframeindividual_dets = structure(list(location = c("ARB-04", "BIRCHY HEAD", "Boca1", "BON-AR-S2",...

View Article


Extract data from specific cells in multiple excel files - R

I need to extract data (date, time) from two cells (E6:E7) from multiple excel files and then store that data into a data frame (with separate columns for date and time). See below for the code I've...

View Article

For loop over dygraph does not work in R

There is some strange behavior on dygraph.When using a for loop for dygraph i get no result. library(dygraphs) lungDeaths <- cbind(mdeaths, fdeaths) for(i in 1:2){ dygraph(lungDeaths[, i]) } On the...

View Article

Winnow data.frame to principle text-containing columns?

I would like to identify a sensible method to detect and select the ‘principle’ text-containing data columns from my data.frames.These columns contain open-ended survey responses, so they have...

View Article


tryCatch: access object from expr in warning statement?

I have a glmer model that throws a gradient convergence warning, e.g.:Warning message: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| =...

View Article


How to unset proxy for r and rstudio?

I am using ubuntu and at work, I set up proxy settings to use rstudio. When I'm home I unset the proxy settings by editing the file /etc/apt/apt.conf.d/80proxy and .Rprofile and environment. I can use...

View Article

Knitting returns parse error

In attempting to knit a PDF. I'm calling a script that should return two ggplots by calling the chunk:```{r, echo=FALSE} read_chunk('Script.R') ```r But receive the errorprocessing file:...

View Article

How to replace values from variable A and B with NA if value of A is lower...

How to replace values of variable-A and variable-B with NA if the variable-A value is smaller than the corresponding value in variable B. It is in R. I know that I have to use some sort of for-if-else...

View Article

Merging data frames with partial Matching using R

Lets say I have data frame df1 with the following variablesContinent Country 1 Europe Russia 2 Asia Myanmar (Burma) 3 africa Benin 4 africa Botswana 5 africa Burkina and df2 with the following...

View Article


Project MaxENT fitted model into geographic space

Similar question was answered here; however, this problem is a bit different for which I cannot apply that solution. I have fitted maxent using site-with-data format. The problem is I cannot project...

View Article

How to get pathview plot displayed directly (rather than saving as a file) in R?

Here is an example and the output is a png file hsa04110.gse16873.png. My question is how to get the plot displayed directly rather than save it as a file.library(pathview) data(gse16873.d)...

View Article


Importing several lines in a txt file to a single case in R

I'm starting to analyze mikrotik devices on a network, an i'm importing the syslog files of mikrotik in R. Files containing structures like this:0 interface=wlan1 radio-name="sxt lite5 ac"...

View Article

Define keybindings for R in Visual Studio Code

I'm using Visual Studio Code to write and edit my R-scripts. Therefore I want to create some keybindings like:nrow(*selected*)length(*selected*)So i installed the 'R Extension Pack' (with R & R LSP...

View Article


Creating a function, accidentally overwriting the output

I am new to R so this is probably quite simple, but I am having an issue with the function I wrote- I need it to return an updated dataframe but it's returning the original.I've created a function in R...

View Article

Error: `week` and `month` must evaluate to column positions or names, not a...

Now I am trying to create a sunbrust plot for the number of births with the inner ring equals to Q1, Q2, Q3 and Q4, the middle ring equals to months and the outer most ring equals to week of the day.My...

View Article

R find replace in data frame

I tried to find an answer for this in other posts but nothing seemed to be working.I have a data set where people answered the city they were in using a free response format. Therefore for each city,...

View Article
Browsing all 201839 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>